public record Money(long cents, String currency) { public Money { if (cents < 0) throw new IllegalArgumentException("negative"); currency = currency.toUpperCase(); } public Money plus(Money other) { if (!currency.equals(other.currency)) throw new IllegalArgumentException("currency"); return new Money(cents + other.cents, currency); } }