Skip to content

Commit

Permalink
fix: update KeyValuePair.equals to only compare key (not value) (#347)
Browse files Browse the repository at this point in the history
Signed-off-by: Jeromy Cannon <[email protected]>
  • Loading branch information
jeromy-cannon authored Sep 15, 2023
1 parent 208cf55 commit 28222e0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static <K, V> KeyValuePair<K, V> of(final K key, final V value) {
public boolean equals(final Object o) {
if (this == o) return true;
if (!(o instanceof KeyValuePair<?, ?> that)) return false;
return Objects.equals(key, that.key) && Objects.equals(value, that.value);
return Objects.equals(key, that.key);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class KeyValuePairTest {
void testKeyValuePair() {
KeyValuePair<String, String> kvp1 = new KeyValuePair<>("key", "value");
KeyValuePair<String, String> kvp1v2 = new KeyValuePair<>("key", "value2");
assertThat(kvp1).isNotEqualTo(kvp1v2);
assertThat(kvp1).isEqualTo(kvp1v2);
assertThat(kvp1.hashCode()).isEqualTo(kvp1v2.hashCode());
}
}

0 comments on commit 28222e0

Please sign in to comment.