public final class CurrencyAmountArray extends Object implements FxConvertible<CurrencyAmountArray>, org.joda.beans.ImmutableBean, Serializable
This represents an array of CurrencyAmount in a single currency.
Internally, it stores the data using a single Currency and a DoubleArray.
| Modifier and Type | Class and Description |
|---|---|
static class |
CurrencyAmountArray.Meta
The meta-bean for
CurrencyAmountArray. |
| 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) |
CurrencyAmount |
get(int index)
Gets the amount at the specified index.
|
Currency |
getCurrency()
Gets the currency.
|
DoubleArray |
getValues()
Gets the values.
|
int |
hashCode() |
static CurrencyAmountArray.Meta |
meta()
The meta-bean for
CurrencyAmountArray. |
CurrencyAmountArray.Meta |
metaBean() |
CurrencyAmountArray |
minus(CurrencyAmount amount)
Returns a new array containing the values from this array with the specified amount subtracted.
|
CurrencyAmountArray |
minus(CurrencyAmountArray other)
Returns a new array containing the values from this array with the values from the other array subtracted.
|
static CurrencyAmountArray |
of(Currency currency,
DoubleArray values)
Obtains an instance from the specified currency and array of values.
|
static CurrencyAmountArray |
of(int size,
IntFunction<CurrencyAmount> valueFunction)
Obtains an instance using a function to create the entries.
|
static CurrencyAmountArray |
of(List<CurrencyAmount> amounts)
Obtains an instance from the specified list of amounts.
|
CurrencyAmountArray |
plus(CurrencyAmount amount)
Returns a new array containing the values from this array with the specified amount added.
|
CurrencyAmountArray |
plus(CurrencyAmountArray 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<CurrencyAmount> |
stream()
Returns a stream of the amounts.
|
String |
toString() |
public static CurrencyAmountArray of(Currency currency, DoubleArray values)
currency - the currency of the valuesvalues - the valuespublic static CurrencyAmountArray of(List<CurrencyAmount> amounts)
All amounts must have the same currency.
amounts - the amounts, at least size oneIllegalArgumentException - if multiple currencies are foundpublic static CurrencyAmountArray of(int size, IntFunction<CurrencyAmount> valueFunction)
The function is passed the index and returns the CurrencyAmount for that index.
In some cases it may be possible to specify the currency with a function providing a double.
To do this, use DoubleArray.of(int, java.util.function.IntToDoubleFunction) and
then call of(Currency, DoubleArray).
size - the number of elements, at least size onevalueFunction - the function used to obtain each valueIllegalArgumentException - is size is zero or lesspublic int size()
public CurrencyAmount get(int index)
index - the zero-based index to retrievepublic Stream<CurrencyAmount> 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 CurrencyAmountArray plus(CurrencyAmountArray other)
The amounts are added to the matching element in this array. The currency must be the same as the currency of this array. The arrays must have the same size.
other - another array of multiple currency values.IllegalArgumentException - if the arrays have different sizes or different currenciespublic CurrencyAmountArray plus(CurrencyAmount amount)
The amount is added to each element in this array. The currency must be the same as the currency of this array.
amount - the amount to addIllegalArgumentException - if the array and the amount have different currenciespublic CurrencyAmountArray minus(CurrencyAmountArray other)
The amounts are subtracted from the matching element in this array. The currency must be the same as the currency of this array. The arrays must have the same size.
other - another array of multiple currency values.IllegalArgumentException - if the arrays have different sizes or different currenciespublic CurrencyAmountArray minus(CurrencyAmount amount)
The amount is subtracted from each element in this array. The currency must be the same as the currency of this array.
amount - the amount to subtractIllegalArgumentException - if the array and the amount have different currenciespublic static CurrencyAmountArray.Meta meta()
CurrencyAmountArray.public CurrencyAmountArray.Meta metaBean()
metaBean in interface org.joda.beans.Beanpublic Currency getCurrency()
public DoubleArray getValues()
Copyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.