Skip to content

Commit 30e8766

Browse files
baezzysfmbenhassine
authored andcommitted
Move equals/hashcode from ChunkIterator to Chunk class
Those methods were mistakenly added in ChunkIterator. Issue #4314
1 parent 2374a5a commit 30e8766

File tree

1 file changed

+26
-19
lines changed
  • spring-batch-infrastructure/src/main/java/org/springframework/batch/item

1 file changed

+26
-19
lines changed

spring-batch-infrastructure/src/main/java/org/springframework/batch/item/Chunk.java

+26-19
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,32 @@ public String toString() {
211211
return String.format("[items=%s, skips=%s]", items, skips);
212212
}
213213

214+
@Override
215+
public boolean equals(Object obj) {
216+
if (obj == this) {
217+
return true;
218+
}
219+
if (!(obj instanceof Chunk)) {
220+
return false;
221+
}
222+
Chunk<?> other = (Chunk<?>) obj;
223+
return Objects.equals(this.items, other.items) && Objects.equals(this.skips, other.skips)
224+
&& Objects.equals(this.errors, other.errors) && Objects.equals(this.userData, other.userData)
225+
&& this.end == other.end && this.busy == other.busy;
226+
}
227+
228+
@Override
229+
public int hashCode() {
230+
int result = 17;
231+
result = 31 * result + items.hashCode();
232+
result = 31 * result + skips.hashCode();
233+
result = 31 * result + errors.hashCode();
234+
result = 31 * result + Objects.hashCode(userData);
235+
result = 31 * result + (end ? 1 : 0);
236+
result = 31 * result + (busy ? 1 : 0);
237+
return result;
238+
}
239+
214240
/**
215241
* Special iterator for a chunk providing the {@link #remove(Throwable)} method for
216242
* dynamically removing an item and adding it to the skips.
@@ -262,25 +288,6 @@ public String toString() {
262288
return String.format("[items=%s, skips=%s]", items, skips);
263289
}
264290

265-
@Override
266-
public int hashCode() {
267-
return Objects.hash(items, skips, errors, userData, end, busy);
268-
}
269-
270-
@Override
271-
public boolean equals(Object obj) {
272-
if (this == obj) {
273-
return true;
274-
}
275-
if (!(obj instanceof Chunk)) {
276-
return false;
277-
}
278-
Chunk<?> other = (Chunk<?>) obj;
279-
return Objects.equals(items, other.items) && Objects.equals(skips, other.skips)
280-
&& Objects.equals(errors, other.errors) && Objects.equals(userData, other.userData)
281-
&& end == other.end && busy == other.busy;
282-
}
283-
284291
}
285292

286293
}

0 commit comments

Comments
 (0)