Exemplo n.º 1
0
  @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()));
  }
Exemplo n.º 2
0
 @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());
 }
Exemplo n.º 3
0
 @Override
 public Amount times(Amount o, RemainderHandler remainderHandler) {
   return new DecimalAmount(bd.multiply(o.asBigDecimal()));
 }
Exemplo n.º 4
0
 @Override
 public Amount minus(Amount o) {
   return new DecimalAmount(bd.subtract(o.asBigDecimal()));
 }
Exemplo n.º 5
0
 @Override
 public Amount plus(Amount o) {
   return new DecimalAmount(bd.add(o.asBigDecimal()));
 }
Exemplo n.º 6
0
 public static DecimalAmount of(Amount amount) {
   return new DecimalAmount(amount.asBigDecimal());
 }