core / Amount / <init>

<init>

Amount(amount: BigDecimal, currency: Currency)


Amount(pennies: Long, currency: Currency)

Amount represents a positive quantity of currency, measured in pennies, which are the smallest representable units.

Note that "pennies" are not necessarily 1/100ths of a currency unit, but are the actual smallest amount used in whatever currency the amount represents.

Amounts of different currencies do not mix and attempting to add or subtract two amounts of different currencies will throw IllegalArgumentException. Amounts may not be negative. Amounts are represented internally using a signed 64 bit value, therefore, the maximum expressable amount is 2^63 - 1 == Long.MAX_VALUE. Addition, subtraction and multiplication are overflow checked and will throw ArithmeticException if the operation would have caused integer overflow.

TODO: It may make sense to replace this with convenience extensions over the JSR 354 MonetaryAmount interface TODO: Should amount be abstracted to cover things like quantities of a stock, bond, commercial paper etc? Probably. TODO: Think about how positive-only vs positive-or-negative amounts can be represented in the type system.