Ratio extends Number implements Comparable<Ratio> { public Money apply(final Money money) { return Money.from(times(money.getValue(), raw), money.getCurrency()); } private  Ratio(final BigDecimal raw); static Ratio fromRaw(final String rate); static Ratio fromRaw(final BigDecimal rate); static Ratio fromPercentage(final String rate); static Ratio fromPercentage(final Number rate); BigDecimal bigDecimalValue(); BigDecimal asPercentage(); Ratio min(final Ratio other); Ratio max(final Ratio other); @Override String toString(); @Override boolean equals(final Object o); Money apply(final Money money); @Override int hashCode(); @Override int compareTo(final Ratio o); @Override int intValue(); @Override long longValue(); @Override float floatValue(); @Override double doubleValue(); static final Ratio ZERO; static final Ratio ONE; }
@Test void apply() { final Money money = Money.from(10); final Ratio ratio = Ratio.fromPercentage("25"); assertThat(ratio.apply(money)).isEqualTo(Money.from("2.5")); }