@Test public void testEquals() { assertEquals(MONEY_1_19_EUR.hashCode(), MONEY_1_19_EUR.hashCode()); assertEquals(MONEY_1_19_EUR, MONEY_1_19_EUR); assertEquals(MONEY_1_19_EUR, Money.valueOf(new BigDecimal("1.190"), EUR)); Money nothing = Money.valueOf(BigDecimal.ZERO, USD); assertTrue(nothing.equals(nothing)); Money nothingInEUR = Money.valueOf(BigDecimal.ZERO, EUR); assertTrue(nothing.equals(nothingInEUR)); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Money other = (Money)obj; if (amount == null) { if (other.amount != null) return false; } else if (!amount.stripTrailingZeros().equals(other.amount.stripTrailingZeros())) return false; if (isZero(this) && isZero(other)) { return true; } if (!currency.equals(other.currency)) return false; return true; }
Money { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Money other = (Money)obj; if (amount == null) { if (other.amount != null) return false; } else if (!amount.stripTrailingZeros().equals(other.amount.stripTrailingZeros())) return false; if (isZero(this) && isZero(other)) { return true; } if (!currency.equals(other.currency)) return false; return true; } }
Money { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Money other = (Money)obj; if (amount == null) { if (other.amount != null) return false; } else if (!amount.stripTrailingZeros().equals(other.amount.stripTrailingZeros())) return false; if (isZero(this) && isZero(other)) { return true; } if (!currency.equals(other.currency)) return false; return true; } private  Money(BigDecimal amount, Currency currency); }
Money { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Money other = (Money)obj; if (amount == null) { if (other.amount != null) return false; } else if (!amount.stripTrailingZeros().equals(other.amount.stripTrailingZeros())) return false; if (isZero(this) && isZero(other)) { return true; } if (!currency.equals(other.currency)) return false; return true; } private  Money(BigDecimal amount, Currency currency); static Money valueOf(MoneyPO money); static Money valueOf(String amount); static Money valueOf(String amount, Currency currency); static Money valueOf(BigDecimal amount, String currency); static Money valueOf(BigDecimal amount, Currency currency); static Money valueOf(String amount, String currencyCode); boolean isZero(); Money add(Money augend); Money divide(BigDecimal divisor); Money divide(BigDecimal divisor, int additionalScale); Money divide(long divisor); @Override boolean equals(Object obj); BigDecimal getAmount(); Currency getCurrency(); Money round(RoundingMode mode); Money round(); Money stripTrailingZeros(); @Override int hashCode(); Money multiply(BigDecimal multiplicand); Money negate(); Money subtract(Money subtrahend); MoneyPO toMoneyPO(); @Override String toString(); }
Money { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Money other = (Money)obj; if (amount == null) { if (other.amount != null) return false; } else if (!amount.stripTrailingZeros().equals(other.amount.stripTrailingZeros())) return false; if (isZero(this) && isZero(other)) { return true; } if (!currency.equals(other.currency)) return false; return true; } private  Money(BigDecimal amount, Currency currency); static Money valueOf(MoneyPO money); static Money valueOf(String amount); static Money valueOf(String amount, Currency currency); static Money valueOf(BigDecimal amount, String currency); static Money valueOf(BigDecimal amount, Currency currency); static Money valueOf(String amount, String currencyCode); boolean isZero(); Money add(Money augend); Money divide(BigDecimal divisor); Money divide(BigDecimal divisor, int additionalScale); Money divide(long divisor); @Override boolean equals(Object obj); BigDecimal getAmount(); Currency getCurrency(); Money round(RoundingMode mode); Money round(); Money stripTrailingZeros(); @Override int hashCode(); Money multiply(BigDecimal multiplicand); Money negate(); Money subtract(Money subtrahend); MoneyPO toMoneyPO(); @Override String toString(); static final Money NOTHING; static final Money ONE_USD; }