Companion

object Companion

Functions

Link copied to clipboard
fun <T : Any> fromDecimal(displayQuantity: BigDecimal, token: T, rounding: RoundingMode = RoundingMode.FLOOR): Amount<T>

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 getDisplayTokenSize is used to determine the conversion scaling, for example bonds might be in nominal amounts of 100, currencies in 0.01 penny units.

Link copied to clipboard

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.

Link copied to clipboard

Returns an amount that is equal to the given currency amount in text. Examples of what is supported:

Link copied to clipboard

If the given iterable of Amounts yields any elements, sum them, throwing an IllegalArgumentException if any of the token types are mismatched; if the iterator yields no elements, return null.

Link copied to clipboard
fun <T : Any> Iterable<Amount<T>>.sumOrThrow(): <Error class: unknown class>

Sums the amounts yielded by the given iterable, throwing an IllegalArgumentException if any of the token types are mismatched.

Link copied to clipboard
fun <T : Any> Iterable<Amount<T>>.sumOrZero(token: T): Amount<T>

If the given iterable of Amounts 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.

Link copied to clipboard
fun <T : Any> zero(token: T): Amount<T>

For a particular token returns a zero sized Amount