public final class MultiCurrencyAmountArray extends Object implements FxConvertible<CurrencyAmountArray>, org.joda.beans.ImmutableBean, Serializable
This represents an array of MultiCurrencyAmount.
Internally, it stores the data using a map of Currency to DoubleArray,
which uses less memory than a List<MultiCurrencyAmount>.
| Modifier and Type | Class and Description |
|---|---|
static class |
MultiCurrencyAmountArray.Meta
The meta-bean for
MultiCurrencyAmountArray. |
| Modifier and Type | Method and Description |
|---|---|
CurrencyAmountArray |
convertedTo(Currency resultCurrency,
FxRateProvider fxRateProvider)
Converts this instance to an equivalent amount in the specified currency.
|
boolean |
equals(Object obj) |
MultiCurrencyAmount |
get(int index)
Gets the amount at the specified index.
|
Set<Currency> |
getCurrencies()
Gets the set of currencies for which this object contains values.
|
int |
getSize()
Gets the size of this array.
|
ImmutableSortedMap<Currency,DoubleArray> |
getValues()
Gets the currency values, keyed by currency.
|
DoubleArray |
getValues(Currency currency)
Gets the values for the specified currency, throws an exception if there are no values for the currency.
|
int |
hashCode() |
static MultiCurrencyAmountArray.Meta |
meta()
The meta-bean for
MultiCurrencyAmountArray. |
MultiCurrencyAmountArray.Meta |
metaBean() |
MultiCurrencyAmountArray |
minus(MultiCurrencyAmount amount)
Returns a new array containing the values from this array with the values from the amount subtracted.
|
MultiCurrencyAmountArray |
minus(MultiCurrencyAmountArray other)
Returns a new array containing the values from this array with the values from the other array subtracted.
|
static MultiCurrencyAmountArray |
of(int size,
IntFunction<MultiCurrencyAmount> valueFunction)
Obtains an instance using a function to create the entries.
|
static MultiCurrencyAmountArray |
of(List<MultiCurrencyAmount> amounts)
Obtains an instance from the specified multi-currency amounts.
|
static MultiCurrencyAmountArray |
of(Map<Currency,DoubleArray> values)
Obtains an instance from a map of amounts.
|
static MultiCurrencyAmountArray |
of(MultiCurrencyAmount... amounts)
Obtains an instance from the specified multi-currency amounts.
|
MultiCurrencyAmountArray |
plus(MultiCurrencyAmount amount)
Returns a new array containing the values from this array with the values from the amount added.
|
MultiCurrencyAmountArray |
plus(MultiCurrencyAmountArray other)
Returns a new array containing the values from this array added to the values in the other array.
|
int |
size()
Gets the size of the array.
|
Stream<MultiCurrencyAmount> |
stream()
Returns a stream of the amounts.
|
static Collector<CurrencyAmountArray,?,MultiCurrencyAmountArray> |
toMultiCurrencyAmountArray()
Returns a collector which creates a multi currency amount array by combining a stream of
currency amount arrays.
|
String |
toString() |
static MultiCurrencyAmountArray |
total(Iterable<CurrencyAmountArray> arrays)
Returns a multi currency amount array representing the total of the input arrays.
|
public static MultiCurrencyAmountArray of(MultiCurrencyAmount... amounts)
amounts - the amountspublic static MultiCurrencyAmountArray of(List<MultiCurrencyAmount> amounts)
amounts - the amountspublic static MultiCurrencyAmountArray of(int size, IntFunction<MultiCurrencyAmount> valueFunction)
The function is passed the index and returns the MultiCurrencyAmount for that index.
size - the number of elements, at least size onevalueFunction - the function used to obtain each valueIllegalArgumentException - is size is zero or lesspublic static MultiCurrencyAmountArray of(Map<Currency,DoubleArray> values)
Each currency is associated with an array of amounts. All the arrays must have the same number of elements.
If the map is empty the returned array will have a size of zero. To create an empty array
with a non-zero size use one of the other of methods.
values - map of currencies to valuespublic Set<Currency> getCurrencies()
public DoubleArray getValues(Currency currency)
currency - the currency for which values are requiredIllegalArgumentException - if there are no values for the currencypublic int size()
public MultiCurrencyAmount get(int index)
index - the zero-based index to retrievepublic Stream<MultiCurrencyAmount> stream()
public CurrencyAmountArray convertedTo(Currency resultCurrency, FxRateProvider fxRateProvider)
FxConvertibleThe result, which may be of a different type, will be expressed in terms of the given currency. Any FX conversion that is required will use rates from the provider.
convertedTo in interface FxConvertible<CurrencyAmountArray>resultCurrency - the currency of the resultfxRateProvider - the provider of FX ratespublic MultiCurrencyAmountArray plus(MultiCurrencyAmountArray other)
The amounts are added to the matching element in this array. The arrays must have the same size.
other - another array of multiple currency values.IllegalArgumentException - if the arrays have different sizespublic MultiCurrencyAmountArray plus(MultiCurrencyAmount amount)
The amount is added to each element in this array.
amount - the amount to addpublic MultiCurrencyAmountArray minus(MultiCurrencyAmountArray other)
The amounts are subtracted from the matching element in this array. The arrays must have the same size.
other - another array of multiple currency values.IllegalArgumentException - if the arrays have different sizespublic MultiCurrencyAmountArray minus(MultiCurrencyAmount amount)
The amount is subtracted from each element in this array.
amount - the amount to subtractpublic static MultiCurrencyAmountArray total(Iterable<CurrencyAmountArray> arrays)
If the input contains the same currency more than once, the amounts are added together.
arrays - the amount arrayspublic static Collector<CurrencyAmountArray,?,MultiCurrencyAmountArray> toMultiCurrencyAmountArray()
The arrays in the stream must all have the same length.
public static MultiCurrencyAmountArray.Meta meta()
MultiCurrencyAmountArray.public MultiCurrencyAmountArray.Meta metaBean()
metaBean in interface org.joda.beans.Beanpublic int getSize()
public ImmutableSortedMap<Currency,DoubleArray> getValues()
Copyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.