public final class MoneyUtils
extends java.lang.Object
This utility class contains thread-safe static methods.
| Modifier and Type | Method | Description |
|---|---|---|
static BigMoney |
add(BigMoney money1,
BigMoney money2) |
Adds two
BigMoney objects, handling null. |
static Money |
add(Money money1,
Money money2) |
Adds two
Money objects, handling null. |
static boolean |
isNegative(BigMoneyProvider moneyProvider) |
Checks if the monetary value is negative and non-zero, treating null as zero.
|
static boolean |
isNegativeOrZero(BigMoneyProvider moneyProvider) |
Checks if the monetary value is negative or zero, treating null as zero.
|
static boolean |
isPositive(BigMoneyProvider moneyProvider) |
Checks if the monetary value is positive and non-zero, treating null as zero.
|
static boolean |
isPositiveOrZero(BigMoneyProvider moneyProvider) |
Checks if the monetary value is positive or zero, treating null as zero.
|
static boolean |
isZero(BigMoneyProvider moneyProvider) |
Checks if the monetary value is zero, treating null as zero.
|
static BigMoney |
max(BigMoney money1,
BigMoney money2) |
Finds the maximum
BigMoney value, handing null. |
static Money |
max(Money money1,
Money money2) |
Finds the maximum
Money value, handing null. |
static BigMoney |
min(BigMoney money1,
BigMoney money2) |
Finds the minimum
BigMoney value, handing null. |
static Money |
min(Money money1,
Money money2) |
Finds the minimum
Money value, handing null. |
static BigMoney |
subtract(BigMoney money1,
BigMoney money2) |
Subtracts the second
BigMoney from the first, handling null. |
static Money |
subtract(Money money1,
Money money2) |
Subtracts the second
Money from the first, handling null. |
public static boolean isZero(BigMoneyProvider moneyProvider)
This method accepts any implementation of BigMoneyProvider.
moneyProvider - the money to check, null returns zeropublic static boolean isPositive(BigMoneyProvider moneyProvider)
This method accepts any implementation of BigMoneyProvider.
moneyProvider - the money to check, null returns falsepublic static boolean isPositiveOrZero(BigMoneyProvider moneyProvider)
This method accepts any implementation of BigMoneyProvider.
moneyProvider - the money to check, null returns truepublic static boolean isNegative(BigMoneyProvider moneyProvider)
This method accepts any implementation of BigMoneyProvider.
moneyProvider - the money to check, null returns falsepublic static boolean isNegativeOrZero(BigMoneyProvider moneyProvider)
This method accepts any implementation of BigMoneyProvider.
moneyProvider - the money to check, null returns truepublic static Money max(Money money1, Money money2)
Money value, handing null.
This returns the greater of money1 or money2 where null is ignored. If both input values are null, then null is returned.
money1 - the first money instance, null returns money2money2 - the first money instance, null returns money1CurrencyMismatchException - if the currencies differpublic static Money min(Money money1, Money money2)
Money value, handing null.
This returns the greater of money1 or money2 where null is ignored. If both input values are null, then null is returned.
money1 - the first money instance, null returns money2money2 - the first money instance, null returns money1CurrencyMismatchException - if the currencies differpublic static Money add(Money money1, Money money2)
Money objects, handling null.
This returns money1 + money2 where null is ignored.
If both input values are null, then null is returned.
money1 - the first money instance, null returns money2money2 - the first money instance, null returns money1CurrencyMismatchException - if the currencies differpublic static Money subtract(Money money1, Money money2)
Money from the first, handling null.
This returns money1 - money2 where null is ignored.
If both input values are null, then null is returned.
money1 - the first money instance, null treated as zeromoney2 - the first money instance, null returns money1CurrencyMismatchException - if the currencies differpublic static BigMoney max(BigMoney money1, BigMoney money2)
BigMoney value, handing null.
This returns the greater of money1 or money2 where null is ignored. If both input values are null, then null is returned.
money1 - the first money instance, null returns money2money2 - the first money instance, null returns money1CurrencyMismatchException - if the currencies differpublic static BigMoney min(BigMoney money1, BigMoney money2)
BigMoney value, handing null.
This returns the greater of money1 or money2 where null is ignored. If both input values are null, then null is returned.
money1 - the first money instance, null returns money2money2 - the first money instance, null returns money1CurrencyMismatchException - if the currencies differpublic static BigMoney add(BigMoney money1, BigMoney money2)
BigMoney objects, handling null.
This returns money1 + money2 where null is ignored.
If both input values are null, then null is returned.
money1 - the first money instance, null returns money2money2 - the first money instance, null returns money1CurrencyMismatchException - if the currencies differpublic static BigMoney subtract(BigMoney money1, BigMoney money2)
BigMoney from the first, handling null.
This returns money1 - money2 where null is ignored.
If both input values are null, then null is returned.
money1 - the first money instance, null treated as zeromoney2 - the first money instance, null returns money1CurrencyMismatchException - if the currencies differCopyright © 2009–2018 Joda.org. All rights reserved.