- java.lang.Object
-
- com.aoapps.lang.i18n.Monies
-
- All Implemented Interfaces:
Comparable<Monies>,Iterable<Money>
public class Monies extends Object implements Comparable<Monies>, Iterable<Money>
Stores multiple monetary values, with one value per currency.- Author:
- AO Industries, Inc.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Moniesadd(Money addend)Moniesadd(Monies addend)intcompareTo(Monies o)booleanequals(Object o)Moneyget(Currency currency)Set<Currency>getCurrencies()Map<Currency,Money>getMap()Collection<Money>getValues()inthashCode()booleanisEmpty()booleanisZero()Check if this is empty or all values are zero.Iterator<Money>iterator()Moniesmultiply(BigDecimal multiplicand)Multiplies without rounding.Moniesmultiply(BigDecimal multiplicand, RoundingMode roundingMode)Multiplies with rounding.Moniesnegate()Returns with monetary amounts that are the negative of these amounts.static Moniesof()static Moniesof(Money money)static Moniesof(Money... monies)Combines all the provided the money, adding together any that have the same currency.static Moniesof(Iterable<Money> monies)Combines all the provided the money, adding together any that have the same currency.MoniesremoveZeros()Removes all currencies with a zero monetary value.intsize()Moniessubtract(Money subtrahend)Moniessubtract(Monies subtrahend)StringtoString()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 Detail
-
of
public static Monies of()
-
of
public static Monies of(Money... monies)
Combines all the provided the money, adding together any that have the same currency.
-
of
public static Monies of(Iterable<Money> monies)
Combines all the provided the money, adding together any that have the same currency.
-
compareTo
public int compareTo(Monies o)
Compares twoMoniesby comparing each value matched byCurrency. During comparison, any currency not set is handled as zero.Two
Moniesare not comparable when they have a conflict where one currency is higher and a different currency is lower.- Specified by:
compareToin interfaceComparable<Monies>
-
isEmpty
public boolean isEmpty()
-
size
public int size()
-
getValues
public Collection<Money> getValues()
-
toString
public String toString()
Displays as a comma-separated list ofMoney.toString()or""for an empty set.- Overrides:
toStringin classObject- See Also:
Money.toString()
-
add
public Monies add(Money addend) throws ArithmeticException
- Throws:
ArithmeticException- See Also:
Money.add(com.aoapps.lang.i18n.Money)
-
add
public Monies add(Monies addend) throws ArithmeticException
- Throws:
ArithmeticException- See Also:
Money.add(com.aoapps.lang.i18n.Money)
-
multiply
public Monies multiply(BigDecimal multiplicand) throws ArithmeticException
Multiplies without rounding.- Throws:
ArithmeticException- See Also:
Money.multiply(java.math.BigDecimal)
-
multiply
public Monies multiply(BigDecimal multiplicand, RoundingMode roundingMode) throws ArithmeticException
Multiplies with rounding.
-
negate
public Monies negate()
Returns with monetary amounts that are the negative of these amounts.- See Also:
Money.negate()
-
subtract
public Monies subtract(Money subtrahend) throws ArithmeticException
- Throws:
ArithmeticException- See Also:
Money.subtract(com.aoapps.lang.i18n.Money)
-
subtract
public Monies subtract(Monies subtrahend) throws ArithmeticException
- Throws:
ArithmeticException- See Also:
Money.subtract(com.aoapps.lang.i18n.Money)
-
isZero
public boolean isZero()
Check if this is empty or all values are zero.
-
removeZeros
public Monies removeZeros()
Removes all currencies with a zero monetary value.
-
-