Skip to content

Commit

Permalink
Implement hashCode for Money
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Apr 11, 2024
1 parent 69dca4e commit bbbe74c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,9 @@ public boolean equals(Object obj) {
return false;
}
}

@Override
public int hashCode() {
return Objects.hash(currency, amount);
}
}
5 changes: 5 additions & 0 deletions src/test/java/org/opentripplanner/routing/core/MoneyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,9 @@ void greaterThan() {
void serializable() {
assertInstanceOf(Serializable.class, oneDollar);
}

@Test
void equalHashCode() {
assertEquals(Money.usDollars(5).hashCode(), Money.usDollars(5).hashCode());
}
}

0 comments on commit bbbe74c

Please sign in to comment.