Package-level declarations

Core functions and types.

Types

Link copied to clipboard

Represents a circulating currency. De facto currencies, albeit not ISO-standardized, are also available (e.g., CNH for Hong Kong's Renminbi).

Link copied to clipboard

Represents a cryptocurrency (also known as Digital Token).

Link copied to clipboard
sealed class Currency : Comparable<Currency>

Represents a currency, a system of money in common use within a specific environment over time.

Link copied to clipboard
sealed interface CurrencyType

Represents the type of Currency.

Link copied to clipboard

Represents a custom currency identified by a code. This object can be used to represent:

Link copied to clipboard

Represents a monetary value.

Link copied to clipboard

Represents a standardized currency. A StandardizedCurrency can be created with an ISO 4217 code (e.g., USD for the United States Dollar, EUR for the Euro, and so on) or with an ISO 24165 (Digital Token Identifier, e.g., 4H95J0R2X for Bitcoin and X9J9K872S for Ethereum) through the Currency.of method.

Functions

Link copied to clipboard
infix fun Percentage.decrease(money: Money): Money

Decreases a given Money by this Percentage.

Link copied to clipboard

Decreases this Money by the given Percentage.

Link copied to clipboard
infix fun Money.exchange(rate: Money): Money

Converts a Money to another currency by the given exchange rate. Calculations using the resulting Money will be rounded with the strategy of the given rate object.

Link copied to clipboard
infix fun Percentage.increase(money: Money): Money

Increases a given Money by this Percentage.

Link copied to clipboard

Increases this Money by the given Percentage.

Link copied to clipboard
infix fun Currency.money(amount: Number): Money

Creates a Money based on this Currency. Example:

infix fun Currency.money(values: Iterable<Number>): Iterable<Money>

Transforms a collection of Number into Money based on this Currency. Calculations using them are rounded using a Rounding strategy configured with RoundingMode.HALF_EVEN.

infix fun Number.money(currency: Currency): Money
infix fun Number.money(currency: String): Money
fun Number.money(currency: String, minorUnits: Int): Money

Creates a Money based on this Number. Calculations using it are rounded using a Rounding strategy configured with RoundingMode.HALF_EVEN.

infix fun String.money(locale: Locale): Money
infix fun String.money(minorUnits: Int): Money

Shorthand for String.money.

infix fun Iterable<Number>.money(currency: Currency): Iterable<Money>
infix fun Iterable<Number>.money(currency: String): Iterable<Money>

Transforms a collection of Number into Money. Calculations using them are rounded using a Rounding strategy configured with RoundingMode.HALF_EVEN.

fun Currency.money(amount: Number, mode: RoundingMode): Money

Creates a Money based on this Currency. Calculations using it are rounded using a Rounding strategy configured with the specified mode.

Transforms a collection of Number into Money based on this Currency. Calculations using them are rounded using a Rounding strategy configured with the specified mode.

fun Number.money(currency: Currency, mode: RoundingMode): Money
fun Number.money(currency: String, mode: RoundingMode): Money
fun Number.money(currency: String, mode: RoundingMode, minorUnits: Int? = null): Money

Creates a Money based on this Number. Calculations using it are rounded using a Rounding strategy configured with the specified mode.

Transforms a collection of Number into Money. Calculations using it are rounded using a Rounding strategy configured with the specified mode.

fun String.money(mode: RoundingMode = defaultRoundingMode, locale: Locale = Locale.getDefault(), minorUnits: Int? = null): Money

Creates a Money based on this String. Example:

Link copied to clipboard

Creates a Money representing the smallest unit of value based on this Currency. Example:

Creates a Money based on this instance but with the monetary amount set to the smallest unit of the currency. Example:

Creates a Money representing the smallest unit of value based on this Currency. Calculations using it are rounded using a Rounding strategy configured with the specified mode.

Link copied to clipboard

Sums all Money elements in the collection.

Link copied to clipboard
operator fun Percentage.times(money: Money): Money

Multiplies a given Money by this Percentage.

operator fun Money.times(by: Percentage): Money

Multiplies this Money by the given Percentage.

operator fun Number.times(money: Money): Money

Multiplies a given Money by this Number.

Link copied to clipboard

Returns a string representation of the object, including all public properties.

Link copied to clipboard

Creates a Money based on this Currency with its amount set to zero. Example:

Creates a Money based on this instance but with the monetary amount set to zero. Example:

infix fun Currency.zero(mode: RoundingMode): Money

Creates a Money based on this Currency with its amount set to zero. Calculations using it are rounded using a Rounding strategy configured with the specified mode.