Money implements Comparable<Money> { public Money max(final Money money) { return compareTo(money) >= 0 ? this : money; } private  Money(final BigDecimal value, final Currency currency); static Money sum(Collection<Money> money); static Money sum(Stream<Money> money); static Money from(final String number); static Money from(final String number, final Currency currency); static Money from(final BigDecimal number); static Money from(final BigDecimal number, final Currency currency); static Money from(final long number); static Money from(final long number, final Currency currency); static Money from(final double number); static Money from(final double number, final Currency currency); static Money getZero(final Currency currency); BigDecimal getValue(); Currency getCurrency(); Money add(final BigDecimal amount); Money add(final long amount); Money add(final double amount); Money add(final Money money); Money subtract(final BigDecimal amount); Money subtract(final long amount); Money subtract(final double amount); Money subtract(final Money money); Money multiplyBy(final BigDecimal amount); Money multiplyBy(final long amount); Money multiplyBy(final Money money); Money divideBy(final BigDecimal amount); Money divideBy(final long amount); Money divideBy(final Money money); Money min(final Money money); Money max(final Money money); boolean isZero(); Money getZero(); @Override String toString(); @Override boolean equals(final Object o); @Override int hashCode(); @Override int compareTo(Money o); static final Money ZERO; }
@Test void max() { Money smaller = Money.from(0); Money larger = Money.from(1); assertSoftly(softly -> { softly.assertThat(smaller.max(larger)) .isSameAs(larger); softly.assertThat(smaller.max(smaller)) .isSameAs(smaller); softly.assertThat(larger.max(smaller)) .isSameAs(larger); }); }