com.r3corda.core.contracts / Amount
Amount
data class Amount<T> : Comparable<Amount<T>>
Amount represents a positive quantity of some token (currency, asset, etc.), measured in quantity of the smallest
representable units. Note that quantity is not necessarily 1/100ths of a currency unit, but are the actual smallest
amount used in whatever underlying thing the amount represents.
Amounts of different tokens 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,
in particular for use during calculations. This may also resolve...
TODO: Think about how positive-only vs positive-or-negative amounts can be represented in the type system.
TODO: Add either a scaling factor, or a variant for use in calculations
Parameters
T
- the type of the token, for example Currency.
Constructors
<init> |
Amount(amount: BigDecimal, currency: T) Amount(quantity: Long, token: T) Amount represents a positive quantity of some token (currency, asset, etc.), measured in quantity of the smallest
representable units. Note that quantity is not necessarily 1/100ths of a currency unit, but are the actual smallest
amount used in whatever underlying thing the amount represents.
|
Properties
Functions
compareTo |
fun compareTo(other: Amount<T>): Int |
div |
operator fun div(other: Long): Amount<T>
operator fun div(other: Int): Amount<T> |
minus |
operator fun minus(other: Amount<T>): Amount<T> |
plus |
operator fun plus(other: Amount<T>): Amount<T> |
times |
operator fun times(other: Long): Amount<T>
operator fun times(other: Int): Amount<T> |
toString |
fun toString(): String |
Extension Properties
Extension Functions