Skip to content

Commit cdc872a

Browse files
authored
chore: use objects compat hash function (#1036)
1 parent a34bdbd commit cdc872a

File tree

1 file changed

+26
-25
lines changed

1 file changed

+26
-25
lines changed

aws-datastore/src/main/java/com/amplifyframework/datastore/syncengine/OutboxMutationFailedEvent.java

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import androidx.annotation.NonNull;
1919
import androidx.annotation.Nullable;
20+
import androidx.core.util.ObjectsCompat;
2021

2122
import com.amplifyframework.api.graphql.GraphQLResponse;
2223
import com.amplifyframework.api.graphql.MutationType;
@@ -51,31 +52,6 @@ private OutboxMutationFailedEvent(
5152
this.model = model;
5253
}
5354

54-
@Override
55-
public boolean equals(Object obj) {
56-
if (this == obj) {
57-
return true;
58-
}
59-
if (obj == null || getClass() != obj.getClass()) {
60-
return false;
61-
}
62-
OutboxMutationFailedEvent<?> that = (OutboxMutationFailedEvent<?>) obj;
63-
return getErrorType() == that.getErrorType() &&
64-
getOperation() == that.getOperation() &&
65-
getModelName().equals(that.getModelName()) &&
66-
getModel().equals(that.getModel());
67-
}
68-
69-
@Override
70-
public int hashCode() {
71-
return Objects.hash(
72-
getErrorType(),
73-
getOperation(),
74-
getModelName(),
75-
getModel()
76-
);
77-
}
78-
7955
/**
8056
* Constructs an outbox mutation error event.
8157
* @param pendingMutation pending mutation that failed to publish
@@ -139,6 +115,31 @@ public HubEvent<OutboxMutationFailedEvent<M>> toHubEvent() {
139115
return HubEvent.create(DataStoreChannelEventName.OUTBOX_MUTATION_FAILED, this);
140116
}
141117

118+
@Override
119+
public boolean equals(Object obj) {
120+
if (this == obj) {
121+
return true;
122+
}
123+
if (obj == null || getClass() != obj.getClass()) {
124+
return false;
125+
}
126+
OutboxMutationFailedEvent<?> that = (OutboxMutationFailedEvent<?>) obj;
127+
return getErrorType() == that.getErrorType() &&
128+
getOperation() == that.getOperation() &&
129+
getModelName().equals(that.getModelName()) &&
130+
getModel().equals(that.getModel());
131+
}
132+
133+
@Override
134+
public int hashCode() {
135+
return ObjectsCompat.hash(
136+
getErrorType(),
137+
getOperation(),
138+
getModelName(),
139+
getModel()
140+
);
141+
}
142+
142143
@Override
143144
public String toString() {
144145
return "OutboxMutationFailedEvent{" +

0 commit comments

Comments
 (0)