This class represents a quantity of money, stored as a BigDecimal amount
in a single currency.
Every currency has a certain standard number of decimal places.
This is typically 2 (Euro, British Pound, US Dollar) but might be
0 (Japanese Yen), 1 (Vietnamese Dong) or 3 (Bahrain Dinar).
The BigMoney class is not restricted to the standard decimal places
and can represent an amount to any precision that a BigDecimal can represent.
This class is immutable and thread-safe.
| Modifier and Type | Field and Description |
|---|---|
| private final BigDecimal | amount
The amount, not null. |
| private final CurrencyUnit | currency
The currency, not null. |
| private static final Pattern | PARSE_REGEX
The regex for parsing. |
| private static final long | serialVersionUID
The serialisation version. |
| Access | Constructor and Description |
|---|---|
| private | |
| pack-priv | BigMoney(CurrencyUnit
the currency to use, not null currency, BigDecimal the amount of money, not null amount)Constructor, creating a new monetary instance. |
| Modifier and Type | Method and Description |
|---|---|
| public BigMoney | Returns: the new instance with the amount converted to be positive, never nullReturns a copy of this monetary value with a positive amount. |
| private BigMoney | checkCurrencyEqual(BigMoneyProvider
the money to check, not null moneyProvider)Validates that the currency of this money and the specified money match. |
| public int | Returns: -1 if this is less than , 0 if equal, 1 if greater thanthe other monetary value, not null other)Implements java. Compares this monetary value to another. |
| public BigMoney | Returns: the new multiplied instance, never nullthe new currency, not null currency, BigDecimal the conversion factor between the currencies, not null conversionMultipler)Returns a copy of this monetary value converted into another currency using the specified conversion rate. |
| public BigMoney | Returns: the new multiplied instance, never nullthe new currency, not null currency, BigDecimal the conversion factor between the currencies, not null conversionMultipler, RoundingMode the rounding mode to use to bring the decimal places back in line, not null roundingMode)Returns a copy of this monetary value converted into another currency using the specified conversion rate, with a rounding mode used to adjust the decimal places in the result. |
| public BigMoney | Returns: the new divided instance, never nullthe scalar value to divide by, not null valueToDivideBy, RoundingMode the rounding mode to use, not null roundingMode)Returns a copy of this monetary value divided by the specified value using the specified rounding mode to adjust the scale. |
| public BigMoney | Returns: the new divided instance, never nullthe scalar value to divide by, not null valueToDivideBy, RoundingMode the rounding mode to use, not null roundingMode)Returns a copy of this monetary value divided by the specified value using the specified rounding mode to adjust the scale. |
| public BigMoney | Returns: the new divided instance, never nullthe scalar value to divide by, not null valueToDivideBy, RoundingMode the rounding mode to use, not null roundingMode)Returns a copy of this monetary value divided by the specified value using the specified rounding mode to adjust the decimal places in the result. |
| public boolean | Returns: true if this instance equals the other instancethe other object, null returns false other)Overrides java. Checks if this monetary value equals another. |
| public BigDecimal | |
| public BigDecimal | Returns: the major units part of the amount, never nullGets the amount in major units as a |
| public int | Returns: the major units part of the amountGets the amount in major units as an |
| public long | Returns: the major units part of the amountGets the amount in major units as a |
| public BigDecimal | Returns: the minor units part of the amount, never nullGets the amount in minor units as a |
| public int | Returns: the minor units part of the amountGets the amount in minor units as an |
| public long | Returns: the minor units part of the amountGets the amount in minor units as a |
| public CurrencyUnit | |
| public int | Returns: the minor part of the amount, negative if the amount is negativeGets the minor part of the amount. |
| public int | |
| public int | Returns: a suitable hash codeOverrides java. Returns a hash code for this monetary value. |
| public boolean | Returns: true if the scale equals the current default scaleChecks if this money has the scale of the currency. |
| public boolean | Returns: true if this is equal to the specified monetary valuethe other monetary value, not null other)Checks if this monetary value is equal to another. |
| public boolean | Returns: true if this is greater than the specified monetary valuethe other monetary value, not null other)Checks if this monetary value is greater than another. |
| public boolean | Returns: true if this is greater than or equal to the specified monetary valuethe other monetary value, not null other)Checks if this monetary value is greater than or equal to another. |
| public boolean | Returns: true if this is less than the specified monetary valuethe other monetary value, not null other)Checks if this monetary value is less than another. |
| public boolean | Returns: true if this is less than or equal to the specified monetary valuethe other monetary value, not null other)Checks if this monetary value is less or equal to than another. |
| public boolean | |
| public boolean | |
| public boolean | Returns: true if the amount is greater than zeroChecks if the amount is greater than zero. |
| public boolean | Returns: true if the amount is zero or greaterChecks if the amount is zero or greater. |
| public boolean | Returns: true if they have the same currencythe money to check, not null money)Checks if this instance and the specified instance have the same currency. |
| public boolean | |
| public BigMoney | Returns: the new instance with the input amounts subtracted, never nullthe monetary values to subtract, no null elements, not null moniesToSubtract)Returns a copy of this monetary value with a collection of monetary amounts subtracted. |
| public BigMoney | Returns: the new instance with the input amount subtracted, never nullthe monetary value to subtract, not null moneyToSubtract)Returns a copy of this monetary value with the amount subtracted. |
| public BigMoney | Returns: the new instance with the input amount subtracted, never nullthe monetary value to subtract, not null amountToSubtract)Returns a copy of this monetary value with the amount subtracted. |
| public BigMoney | Returns: the new instance with the input amount subtracted, never nullthe monetary value to subtract, not null amountToSubtract)Returns a copy of this monetary value with the amount subtracted. |
| public BigMoney | Returns: the new instance with the input amount subtracted, never nullthe monetary value to subtract, not null amountToSubtract)Returns a copy of this monetary value with the amount in major units subtracted. |
| public BigMoney | Returns: the new instance with the input amount subtracted, never nullthe monetary value to subtract, not null amountToSubtract)Returns a copy of this monetary value with the amount in minor units subtracted. |
| public BigMoney | Returns: the new instance with the input amount subtracted, never nullthe monetary value to add, not null moneyToSubtract, RoundingMode the rounding mode to use to adjust the scale, not null roundingMode)Returns a copy of this monetary value with the amount in the same currency subtracted retaining the scale by rounding the result. |
| public BigMoney | Returns: the new instance with the input amount subtracted, never nullthe monetary value to add, not null amountToSubtract, RoundingMode the rounding mode to use to adjust the scale, not null roundingMode)Returns a copy of this monetary value with the amount subtracted retaining the scale by rounding the result. |
| public BigMoney | Returns: the new instance with the input amount subtracted, never nullthe monetary value to add, not null amountToSubtract, RoundingMode the rounding mode to use to adjust the scale, not null roundingMode)Returns a copy of this monetary value with the amount subtracted retaining the scale by rounding the result. |
| public BigMoney | Returns: the new multiplied instance, never nullthe scalar value to multiply by, not null valueToMultiplyBy)Returns a copy of this monetary value multiplied by the specified value. |
| public BigMoney | Returns: the new multiplied instance, never nullthe scalar value to multiply by, not null valueToMultiplyBy)Returns a copy of this monetary value multiplied by the specified value. |
| public BigMoney | Returns: the new multiplied instance, never nullthe scalar value to multiply by, not null valueToMultiplyBy)Returns a copy of this monetary value multiplied by the specified value. |
| public BigMoney | Returns: the new multiplied instance, never nullthe scalar value to multiply by, not null valueToMultiplyBy, RoundingMode the rounding mode to use to bring the decimal places back in line, not null roundingMode)Returns a copy of this monetary value multiplied by the specified value using the specified rounding mode to adjust the scale of the result. |
| public BigMoney | Returns: the new multiplied instance, never nullthe scalar value to multiply by, not null valueToMultiplyBy, RoundingMode the rounding mode to use to bring the decimal places back in line, not null roundingMode)Returns a copy of this monetary value multiplied by the specified value using the specified rounding mode to adjust the scale of the result. |
| public BigMoney | Returns: the new instance with the amount negated, never nullReturns a copy of this monetary value with the amount negated. |
| public static BigMoney | Returns: the new instance, never nullthe currency, not null currency, BigDecimal the amount of money, not null amount)Obtains an instance of |
| public static BigMoney | Returns: the new instance, never nullthe currency, not null currency, double the amount of money, not null amount)Obtains an instance of |
| public static BigMoney | Returns: the new instance, never nullthe money to convert, not null moneyProvider)Obtains an instance of |
| public static BigMoney | Returns: the new instance, never nullthe currency, not null currency, long the amount of money in the major division of the currency amountMajor)Obtains an instance of |
| public static BigMoney | Returns: the new instance, never nullthe currency, not null currency, long the amount of money in the minor division of the currency amountMinor)Obtains an instance of |
| public static BigMoney | Returns: the new instance, never nullthe currency, not null currency, BigDecimal the amount of money, not null amount, int the scale to use, zero or positive scale)Obtains an instance of |
| public static BigMoney | Returns: the new instance, never nullthe currency, not null currency, BigDecimal the amount of money, not null amount, int the scale to use, zero or positive scale, RoundingMode the rounding mode to use, not null roundingMode)Obtains an instance of |
| public static BigMoney | Returns: the new instance, never nullthe currency, not null currency, long the unscaled amount of money unscaledAmount, int the scale to use scale)Obtains an instance of |
| public static BigMoney | |
| public BigMoney | Returns: the new instance with the input amounts added, never nullthe monetary values to add, no null elements, not null moniesToAdd)Returns a copy of this monetary value with a collection of monetary amounts added. |
| public BigMoney | Returns: the new instance with the input amount added, never nullthe monetary value to add, not null moneyToAdd)Returns a copy of this monetary value with the amount added. |
| public BigMoney | Returns: the new instance with the input amount added, never nullthe monetary value to add, not null amountToAdd)Returns a copy of this monetary value with the amount added. |
| public BigMoney | Returns: the new instance with the input amount added, never nullthe monetary value to add, not null amountToAdd)Returns a copy of this monetary value with the amount added. |
| public BigMoney | Returns: the new instance with the input amount added, never nullthe monetary value to add, not null amountToAdd)Returns a copy of this monetary value with the amount in major units added. |
| public BigMoney | Returns: the new instance with the input amount added, never nullthe monetary value to add, not null amountToAdd)Returns a copy of this monetary value with the amount in minor units added. |
| public BigMoney | Returns: the new instance with the input amount added, never nullthe monetary value to add, not null moneyToAdd, RoundingMode the rounding mode to use to adjust the scale, not null roundingMode)Returns a copy of this monetary value with the amount in the same currency added retaining the scale by rounding the result. |
| public BigMoney | Returns: the new instance with the input amount added, never nullthe monetary value to add, not null amountToAdd, RoundingMode the rounding mode to use to adjust the scale, not null roundingMode)Returns a copy of this monetary value with the amount added retaining the scale by rounding the result. |
| public BigMoney | Returns: the new instance with the input amount added, never nullthe monetary value to add, not null amountToAdd, RoundingMode the rounding mode to use to adjust the scale, not null roundingMode)Returns a copy of this monetary value with the amount added retaining the scale by rounding the result. |
| private void | |
| public BigMoney | Returns: the new instance with the amount converted to be positive, never nullthe new scale scale, RoundingMode the rounding mode to use, not null roundingMode)Returns a copy of this monetary value rounded to the specified scale without changing the current scale. |
| public BigMoney | Returns: the money instance, never nullImplements org. Implements the |
| public Money | Returns: the money instance, never nullConverts this money to an instance of |
| public Money | Returns: the money instance, never nullthe rounding mode to use, not null roundingMode)Converts this money to an instance of |
| public String | Returns: the string representation of this monetary value, never nullOverrides java. Gets this monetary value as a string. |
| public static BigMoney | Returns: the total, never nullthe monetary values to total, not empty, no null elements, not null monies)Obtains an instance of |
| public static BigMoney | Returns: the total, never nullthe monetary values to total, not empty, no null elements, not null monies)Obtains an instance of |
| public static BigMoney | Returns: the total, never nullthe currency to total in, not null currency, BigMoneyProvider... the monetary values to total, no null elements, not null monies)Obtains an instance of |
| public static BigMoney | Returns: the total, never nullthe currency to total in, not null currency, Iterable<? extends BigMoneyProvider> the monetary values to total, no null elements, not null monies)Obtains an instance of |
| private BigMoney | Returns: the new instance, never nullthe new amount to use, not null newAmount)Returns a new |
| public BigMoney | Returns: the new instance with the input amount set, never nullthe monetary amount to set in the returned instance, not null amount)Returns a copy of this monetary value with the specified amount. |
| public BigMoney | Returns: the new instance with the input amount set, never nullthe monetary amount to set in the returned instance amount)Returns a copy of this monetary value with the specified amount using a well-defined
conversion from a |
| public BigMoney | Returns: the new instance with the input amount set, never nullReturns a copy of this monetary value with the scale of the currency, truncating the amount if necessary. |
| public BigMoney | Returns: the new instance with the input amount set, never nullthe rounding mode to use, not null roundingMode)Returns a copy of this monetary value with the scale of the currency, using the specified rounding mode if necessary. |
| public BigMoney | Returns: the new instance with the input currency set, never nullthe currency to use, not null currency)Returns a copy of this monetary value with the specified currency. |
| public BigMoney | Returns: the new instance with the input amount set, never nullthe scale to use scale)Returns a copy of this monetary value with the specified scale, truncating the amount if necessary. |
| public BigMoney | Returns: the new instance with the input amount set, never nullthe scale to use scale, RoundingMode the rounding mode to use, not null roundingMode)Returns a copy of this monetary value with the specified scale, using the specified rounding mode if necessary. |
| private Object | |
| public static BigMoney | Returns: the instance representing zero, never nullthe currency, not null currency)Obtains an instance of |
| public static BigMoney | Returns: the instance representing zero, never nullthe currency, not null currency, int the scale to use, zero or positive scale)Obtains an instance of |