mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-02-24 06:47:54 +01:00
MonetaryFormat: Fix equals() and hashCode().
This commit is contained in:
parent
c01450a32c
commit
9dc2abc82e
2 changed files with 16 additions and 2 deletions
|
@ -489,7 +489,7 @@ public final class MonetaryFormat {
|
|||
return false;
|
||||
if (!Objects.equals(this.roundingMode, other.roundingMode))
|
||||
return false;
|
||||
if (!Objects.equals(this.codes, other.codes))
|
||||
if (!Arrays.equals(this.codes, other.codes))
|
||||
return false;
|
||||
if (!Objects.equals(this.codeSeparator, other.codeSeparator))
|
||||
return false;
|
||||
|
@ -501,6 +501,6 @@ public final class MonetaryFormat {
|
|||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(negativeSign, positiveSign, zeroDigit, decimalMark, minDecimals, decimalGroups, shift,
|
||||
roundingMode, codes, codeSeparator, codePrefixed);
|
||||
roundingMode, Arrays.hashCode(codes), codeSeparator, codePrefixed);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -352,4 +352,18 @@ public class MonetaryFormatTest {
|
|||
public void fiat() throws Exception {
|
||||
assertEquals(ONE_EURO, NO_CODE.parseFiat("EUR", "1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEquals() {
|
||||
MonetaryFormat mf1 = new MonetaryFormat(true);
|
||||
MonetaryFormat mf2 = new MonetaryFormat(true);
|
||||
assertEquals(mf1, mf2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHashCode() {
|
||||
MonetaryFormat mf1 = new MonetaryFormat(true);
|
||||
MonetaryFormat mf2 = new MonetaryFormat(true);
|
||||
assertEquals(mf1.hashCode(), mf2.hashCode());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue