Modifier and Type | Method and Description |
---|---|
<T> Amount<T> |
fromDecimal(java.math.BigDecimal displayQuantity,
T token,
java.math.RoundingMode rounding)
Build an Amount from a decimal representation. For example, with an input of "12.34 GBP",
returns an amount with a quantity of "1234" tokens. The function
Amount.Companion.getDisplayTokenSize is used to determine the
conversion scaling, for example bonds might be in nominal amounts of 100, currencies in 0.01 penny units. |
java.math.BigDecimal |
getDisplayTokenSize(java.lang.Object token)
Determines the representation of one Token quantity in BigDecimal. For Currency and Issued
the definitions is taken from Currency defaultFractionDigits property e.g. 2 for USD, or 0 for JPY
so that the automatic token size is the conventional minimum penny amount.
For other possible token types the asset token should implement TokenizableAssetInfo to
correctly report the designed nominal amount.
|
Amount<java.util.Currency> |
parseCurrency(java.lang.String input)
Returns an amount that is equal to the given currency amount in text. Examples of what is supported:
|
<T> java.lang.Void |
sumOrNull(java.lang.Iterable<net.corda.core.contracts.Amount> $receiver)
If the given iterable of
class Amount s yields any elements, sum them, throwing an IllegalArgumentException if
any of the token types are mismatched; if the iterator yields no elements, return null. |
<T> NonExistentClass |
sumOrThrow(java.lang.Iterable<net.corda.core.contracts.Amount> $receiver)
Sums the amounts yielded by the given iterable, throwing an IllegalArgumentException if any of the token
types are mismatched.
|
<T> Amount<T> |
sumOrZero(java.lang.Iterable<net.corda.core.contracts.Amount> $receiver,
T token)
If the given iterable of
class Amount s yields any elements, sum them, throwing an IllegalArgumentException if
any of the token types are mismatched; if the iterator yields no elements, return a zero amount of the given
token type. |
<T> Amount<T> |
zero(T token)
For a particular token returns a zero sized Amount
|
public <T> Amount<T> fromDecimal(java.math.BigDecimal displayQuantity, T token, java.math.RoundingMode rounding)
Build an Amount from a decimal representation. For example, with an input of "12.34 GBP",
returns an amount with a quantity of "1234" tokens. The function Amount.Companion.getDisplayTokenSize
is used to determine the
conversion scaling, for example bonds might be in nominal amounts of 100, currencies in 0.01 penny units.
Amount.Companion.getDisplayTokenSize
,
Amount.toDecimal
public <T> Amount<T> zero(T token)
For a particular token returns a zero sized Amount
public java.math.BigDecimal getDisplayTokenSize(java.lang.Object token)
Determines the representation of one Token quantity in BigDecimal. For Currency and Issued the definitions is taken from Currency defaultFractionDigits property e.g. 2 for USD, or 0 for JPY so that the automatic token size is the conventional minimum penny amount. For other possible token types the asset token should implement TokenizableAssetInfo to correctly report the designed nominal amount.
public <T> java.lang.Void sumOrNull(java.lang.Iterable<net.corda.core.contracts.Amount> $receiver)
If the given iterable of class Amount
s yields any elements, sum them, throwing an IllegalArgumentException if
any of the token types are mismatched; if the iterator yields no elements, return null.
class Amount
,
IllegalArgumentExceptionpublic <T> NonExistentClass sumOrThrow(java.lang.Iterable<net.corda.core.contracts.Amount> $receiver)
Sums the amounts yielded by the given iterable, throwing an IllegalArgumentException if any of the token types are mismatched.
public <T> Amount<T> sumOrZero(java.lang.Iterable<net.corda.core.contracts.Amount> $receiver, T token)
If the given iterable of class Amount
s yields any elements, sum them, throwing an IllegalArgumentException if
any of the token types are mismatched; if the iterator yields no elements, return a zero amount of the given
token type.
class Amount
,
IllegalArgumentExceptionpublic Amount<java.util.Currency> parseCurrency(java.lang.String input)
Returns an amount that is equal to the given currency amount in text. Examples of what is supported:
12 USD
14.50 USD
10 USD
30 CHF
$10.24
£13
€5000
Note this method does NOT respect internationalisation rules: it ignores commas and uses . as the decimal point separator, always. It also ignores the users locale:
$ is always USD,
£ is always GBP
€ is always the Euro
¥ is always Japanese Yen.
₽ is always the Russian ruble.
Thus an input of $12 expecting some other countries dollar will not work. Do your own parsing if you need correct handling of currency amounts with locale-sensitive handling.