Skip to content

Commit 81248cf

Browse files
author
Michael Li
committed
Adding hashCode and equals method to batchOverrideConfiguration and testing it.
1 parent 3c8d25c commit 81248cf

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

core/sdk-core/src/main/java/software/amazon/awssdk/core/BatchOverrideConfiguration.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,34 @@ public String toString() {
8282
.build();
8383
}
8484

85+
@Override
86+
public boolean equals(Object o) {
87+
if (this == o) {
88+
return true;
89+
}
90+
if (o == null || getClass() != o.getClass()) {
91+
return false;
92+
}
93+
94+
BatchOverrideConfiguration that = (BatchOverrideConfiguration) o;
95+
96+
if (maxBatchItems != null ? !maxBatchItems.equals(that.maxBatchItems) : that.maxBatchItems != null) {
97+
return false;
98+
}
99+
if (maxBatchOpenInMs != null ? !maxBatchOpenInMs.equals(that.maxBatchOpenInMs) : that.maxBatchOpenInMs != null) {
100+
return false;
101+
}
102+
return scheduledExecutor.equals(that.scheduledExecutor);
103+
}
104+
105+
@Override
106+
public int hashCode() {
107+
int result = maxBatchItems != null ? maxBatchItems.hashCode() : 0;
108+
result = 31 * result + (maxBatchOpenInMs != null ? maxBatchOpenInMs.hashCode() : 0);
109+
result = 31 * result + scheduledExecutor.hashCode();
110+
return result;
111+
}
112+
85113
public static final class Builder implements CopyableBuilder<Builder, BatchOverrideConfiguration> {
86114

87115
private Integer maxBatchItems;

core/sdk-core/src/test/java/software/amazon/awssdk/core/BatchOverrideConfigurationTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,13 @@ public void createNewBatchOverrideConfiguration() {
5353
}
5454

5555
@Test
56-
public void creatingCopyWithToBuilder() {
56+
public void creatingCopyWithToBuilderAndCheckEqual() {
5757
BatchOverrideConfiguration overrideConfigurationCopy = overrideConfiguration.toBuilder().build();
5858
Assert.assertEquals(maxBatchItems, overrideConfigurationCopy.maxBatchItems().intValue());
5959
Assert.assertEquals(maxBatchOpenInMs, overrideConfigurationCopy.maxBatchOpenInMs().toMillis());
6060
Assert.assertEquals(scheduledExecutor, overrideConfigurationCopy.scheduledExecutor());
61+
Assert.assertEquals(overrideConfiguration, overrideConfigurationCopy);
62+
Assert.assertEquals(overrideConfiguration.hashCode(), overrideConfigurationCopy.hashCode());
6163
}
6264

6365
@Test

0 commit comments

Comments
 (0)