@Test public void testEquals() { assertEquals(new Quantity(new BigDecimal("700.00"), Unit.GRAM).hashCode(), new Quantity(new BigDecimal("700"), Unit.GRAM).hashCode()); assertEquals(new Quantity(new BigDecimal("700.00"), Unit.GRAM), new Quantity(new BigDecimal("700"), Unit.GRAM)); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Quantity other = (Quantity)obj; if (amount == null) { if (other.amount != null) return false; } else if (!getTrimmedAmount().equals(other.getTrimmedAmount())) return false; if (unit == null) { if (other.unit != null) return false; } else if (!unit.equals(other.unit)) return false; return true; }
Quantity { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Quantity other = (Quantity)obj; if (amount == null) { if (other.amount != null) return false; } else if (!getTrimmedAmount().equals(other.getTrimmedAmount())) return false; if (unit == null) { if (other.unit != null) return false; } else if (!unit.equals(other.unit)) return false; return true; } }
Quantity { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Quantity other = (Quantity)obj; if (amount == null) { if (other.amount != null) return false; } else if (!getTrimmedAmount().equals(other.getTrimmedAmount())) return false; if (unit == null) { if (other.unit != null) return false; } else if (!unit.equals(other.unit)) return false; return true; } Quantity(BigDecimal amount);  Quantity(BigDecimal amount, Unit unit);  Quantity(BigDecimal amount, UnitScale scale, Unit unit); }
Quantity { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Quantity other = (Quantity)obj; if (amount == null) { if (other.amount != null) return false; } else if (!getTrimmedAmount().equals(other.getTrimmedAmount())) return false; if (unit == null) { if (other.unit != null) return false; } else if (!unit.equals(other.unit)) return false; return true; } Quantity(BigDecimal amount);  Quantity(BigDecimal amount, Unit unit);  Quantity(BigDecimal amount, UnitScale scale, Unit unit); static Quantity getInstance(QuantityPO quantity); BigDecimal divide(Quantity divisor); @Override boolean equals(Object obj); BigDecimal getAmount(); UnitScale getScale(); BigDecimal getTrimmedAmount(); Unit getUnit(); @Override int hashCode(); QuantityPO toQuantityPO(); @Override String toString(); }
Quantity { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Quantity other = (Quantity)obj; if (amount == null) { if (other.amount != null) return false; } else if (!getTrimmedAmount().equals(other.getTrimmedAmount())) return false; if (unit == null) { if (other.unit != null) return false; } else if (!unit.equals(other.unit)) return false; return true; } Quantity(BigDecimal amount);  Quantity(BigDecimal amount, Unit unit);  Quantity(BigDecimal amount, UnitScale scale, Unit unit); static Quantity getInstance(QuantityPO quantity); BigDecimal divide(Quantity divisor); @Override boolean equals(Object obj); BigDecimal getAmount(); UnitScale getScale(); BigDecimal getTrimmedAmount(); Unit getUnit(); @Override int hashCode(); QuantityPO toQuantityPO(); @Override String toString(); static final Quantity ONE_PCS; static final Quantity TEN_PCS; }