@Override public Amount dividedBy(Amount o, RemainderHandler remainderHandler) { int scale = Math.max(o.asBigDecimal().scale(), mc.getPrecision()); return new DecimalAmount( bd.divide(o.asBigDecimal(), remainderHandler.getRoundingMode()) .setScale(scale, remainderHandler.getRoundingMode())); }
@Override public int compareTo(@SuppressWarnings("NullableProblems") Amount o) { if (o instanceof DecimalAmount) { DecimalAmount decimalAmount = (DecimalAmount) o; return bd.compareTo(decimalAmount.bd); } return bd.compareTo(o.asBigDecimal()); }
@Override public Amount times(Amount o, RemainderHandler remainderHandler) { return new DecimalAmount(bd.multiply(o.asBigDecimal())); }
@Override public Amount minus(Amount o) { return new DecimalAmount(bd.subtract(o.asBigDecimal())); }
@Override public Amount plus(Amount o) { return new DecimalAmount(bd.add(o.asBigDecimal())); }
public static DecimalAmount of(Amount amount) { return new DecimalAmount(amount.asBigDecimal()); }