@Override public boolean equals(Object obj) { if (!(obj instanceof Money)) { return false; } Money value = (Money) obj; return this.value.compareTo(value.getValue()) == 0; }
@Override protected AbstractValue divMoney(Money value) { if (this.value.compareTo(new BigDecimal(0)) == 0) { // Prevent division by zero. return new Money(this.value); } else { return new Money(value.getValue().divide(this.value, Money.ROUNDING_MODE)); } }
@Override protected AbstractValue subMoney(Money value) { return new Money(value.getValue().subtract(this.value)); }
@Override protected AbstractValue mulMoney(Money value) { return new Money(value.getValue().multiply(this.value)); }
@Override protected AbstractValue addMoney(Money value) { return new Money(value.getValue().add(this.value)); }
@Override public AbstractValue ltMoney(Money value) { return new Bool(value.getValue().compareTo(this.value) == -1); }
@Override public AbstractValue geqMoney(Money value) { return new Bool(value.getValue().compareTo(this.value) >= 0); }