Example #1
0
 public MoneyAmount copy() {
   return MoneyAmount.of(getNumber(), getCurrency());
 }
Example #2
0
 public MoneyAmount divide(long n) {
   return MoneyAmount.of(getNumber().longValue() / n, getCurrency());
 }
Example #3
0
 protected MoneyAmount divide(MoneyAmount that) {
   Unit<?> unit = unit().divide(that.unit());
   return MoneyAmount.of(((BigDecimal) getNumber()).divide((BigDecimal) that.getNumber()), unit);
 }
Example #4
0
 protected MoneyAmount times(MoneyAmount that) {
   Unit<?> unit = unit().multiply(that.unit());
   return MoneyAmount.of(((BigDecimal) getNumber()).multiply((BigDecimal) that.getNumber()), unit);
 }
Example #5
0
 public MoneyAmount pow(int exp) {
   return MoneyAmount.of(((BigDecimal) getNumber()).pow(BigDecimal.valueOf(exp)), unit().pow(exp));
 }
Example #6
0
 public MoneyAmount multiply(long n) {
   return MoneyAmount.of(getNumber().longValue() * n, getCurrency());
 }
Example #7
0
 public MoneyAmount multiply(Number that) {
   return MoneyAmount.of(getNumber().doubleValue() * that.doubleValue(), getCurrency());
 }
Example #8
0
 protected MoneyAmount minus(MoneyAmount that) {
   // MoneyAmount amount = that.to((Unit) getCurrency());
   return MoneyAmount.of(
       this.getNumber().doubleValue() - that.getNumber().doubleValue(), getCurrency());
 }
Example #9
0
 protected MoneyAmount plus(MoneyAmount that) {
   // Measure<BigDecimal, ?> amount = that.to((Unit) getCurrency());
   return MoneyAmount.of(
       this.getNumber().doubleValue() + that.getNumber().doubleValue(), getCurrency());
 }
Example #10
0
 /**
  * Returns the money amount corresponding to the specified generic amount.
  *
  * @param amount the raw amount.
  * @return the corresponding money amount stated in an existing {@link Currency}.
  * @throws ClassCastException if the SI unit of the specified amount is not a {@link Currency}.
  */
 public static MoneyAmount of(QuantityAmount<IMoney> amount) {
   // MoneyAmount amountSI = amount.toSI();
   return MoneyAmount.of(
       BigDecimal.valueOf(amount.getValue().doubleValue()), amount.unit().getSystemUnit());
 }