java.lang.Object
com.aoapps.lang.i18n.Monies
- All Implemented Interfaces:
Comparable<Monies>
,Iterable<Money>
Stores multiple monetary values, with one value per currency.
- Author:
- AO Industries, Inc.
-
Method Summary
Modifier and TypeMethodDescriptionint
boolean
getMap()
int
hashCode()
boolean
isEmpty()
boolean
isZero()
Check if this is empty or all values are zero.iterator()
multiply
(BigDecimal multiplicand) Multiplies without rounding.multiply
(BigDecimal multiplicand, RoundingMode roundingMode) Multiplies with rounding.negate()
Returns with monetary amounts that are the negative of these amounts.static Monies
of()
static Monies
static Monies
Combines all the provided the money, adding together any that have the same currency.static Monies
Combines all the provided the money, adding together any that have the same currency.Removes all currencies with a zero monetary value.int
size()
toString()
Displays as a comma-separated list ofMoney.toString()
or""
for an empty set.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
of
-
of
-
of
Combines all the provided the money, adding together any that have the same currency. -
of
Combines all the provided the money, adding together any that have the same currency. -
equals
-
hashCode
public int hashCode() -
compareTo
Compares twoMonies
by comparing each value matched byCurrency
. During comparison, any currency not set is handled as zero.Two
Monies
are not comparable when they have a conflict where one currency is higher and a different currency is lower.- Specified by:
compareTo
in interfaceComparable<Monies>
-
iterator
-
get
-
getMap
-
isEmpty
public boolean isEmpty() -
size
public int size() -
getCurrencies
-
getValues
-
toString
Displays as a comma-separated list ofMoney.toString()
or""
for an empty set. -
add
- Throws:
ArithmeticException
- See Also:
-
add
- Throws:
ArithmeticException
- See Also:
-
multiply
Multiplies without rounding.- Throws:
ArithmeticException
- See Also:
-
multiply
public Monies multiply(BigDecimal multiplicand, RoundingMode roundingMode) throws ArithmeticException Multiplies with rounding.- Throws:
ArithmeticException
- See Also:
-
negate
Returns with monetary amounts that are the negative of these amounts.- See Also:
-
subtract
- Throws:
ArithmeticException
- See Also:
-
subtract
- Throws:
ArithmeticException
- See Also:
-
isZero
public boolean isZero()Check if this is empty or all values are zero. -
removeZeros
Removes all currencies with a zero monetary value.
-