Class CurrencyAmountArray
- java.lang.Object
-
- com.opengamma.strata.basics.currency.CurrencyAmountArray
-
- All Implemented Interfaces:
FxConvertible<CurrencyAmountArray>,Serializable,org.joda.beans.Bean,org.joda.beans.ImmutableBean
public final class CurrencyAmountArray extends Object implements FxConvertible<CurrencyAmountArray>, org.joda.beans.ImmutableBean, Serializable
An array of currency amounts with the same currency.This represents an array of
CurrencyAmountin a single currency. Internally, it stores the data using a singleCurrencyand aDoubleArray.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCurrencyAmountArray.MetaThe meta-bean forCurrencyAmountArray.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CurrencyAmountArrayconvertedTo(Currency resultCurrency, FxRateProvider fxRateProvider)Converts this instance to an equivalent amount in the specified currency.booleanequals(Object obj)CurrencyAmountget(int index)Gets the amount at the specified index.CurrencygetCurrency()Gets the currency.DoubleArraygetValues()Gets the values.inthashCode()static CurrencyAmountArray.Metameta()The meta-bean forCurrencyAmountArray.CurrencyAmountArray.MetametaBean()CurrencyAmountArrayminus(CurrencyAmount amount)Returns a new array containing the values from this array with the specified amount subtracted.CurrencyAmountArrayminus(CurrencyAmountArray other)Returns a new array containing the values from this array with the values from the other array subtracted.static CurrencyAmountArrayof(int size, IntFunction<CurrencyAmount> valueFunction)Obtains an instance using a function to create the entries.static CurrencyAmountArrayof(Currency currency, DoubleArray values)Obtains an instance from the specified currency and array of values.static CurrencyAmountArrayof(List<CurrencyAmount> amounts)Obtains an instance from the specified list of amounts.CurrencyAmountArrayplus(CurrencyAmount amount)Returns a new array containing the values from this array with the specified amount added.CurrencyAmountArrayplus(CurrencyAmountArray other)Returns a new array containing the values from this array added to the values in the other array.intsize()Gets the size of the array.Stream<CurrencyAmount>stream()Returns a stream of the amounts.StringtoString()
-
-
-
Method Detail
-
of
public static CurrencyAmountArray of(Currency currency, DoubleArray values)
Obtains an instance from the specified currency and array of values.- Parameters:
currency- the currency of the valuesvalues- the values- Returns:
- an instance with the specified currency and values
-
of
public static CurrencyAmountArray of(List<CurrencyAmount> amounts)
Obtains an instance from the specified list of amounts.All amounts must have the same currency.
- Parameters:
amounts- the amounts, at least size one- Returns:
- an instance with the specified amounts
- Throws:
IllegalArgumentException- if multiple currencies are found
-
of
public static CurrencyAmountArray of(int size, IntFunction<CurrencyAmount> valueFunction)
Obtains an instance using a function to create the entries.The function is passed the index and returns the
CurrencyAmountfor that index.In some cases it may be possible to specify the currency with a function providing a
double. To do this, useDoubleArray.of(int, java.util.function.IntToDoubleFunction)and then callof(Currency, DoubleArray).- Parameters:
size- the number of elements, at least size onevalueFunction- the function used to obtain each value- Returns:
- an instance initialized using the function
- Throws:
IllegalArgumentException- is size is zero or less
-
size
public int size()
Gets the size of the array.- Returns:
- the array size
-
get
public CurrencyAmount get(int index)
Gets the amount at the specified index.- Parameters:
index- the zero-based index to retrieve- Returns:
- the amount at the specified index
-
stream
public Stream<CurrencyAmount> stream()
Returns a stream of the amounts.- Returns:
- a stream of the amounts
-
convertedTo
public CurrencyAmountArray convertedTo(Currency resultCurrency, FxRateProvider fxRateProvider)
Description copied from interface:FxConvertibleConverts this instance to an equivalent amount in the specified currency.The 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.
- Specified by:
convertedToin interfaceFxConvertible<CurrencyAmountArray>- Parameters:
resultCurrency- the currency of the resultfxRateProvider- the provider of FX rates- Returns:
- the converted instance, which should be expressed in the specified currency
-
plus
public CurrencyAmountArray plus(CurrencyAmountArray other)
Returns a new array containing the values from this array added to the values in the other array.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.
- Parameters:
other- another array of multiple currency values.- Returns:
- a new array containing the values from this array added to the values in the other array
- Throws:
IllegalArgumentException- if the arrays have different sizes or different currencies
-
plus
public CurrencyAmountArray plus(CurrencyAmount amount)
Returns a new array containing the values from this array with the specified amount added.The amount is added to each element in this array. The currency must be the same as the currency of this array.
- Parameters:
amount- the amount to add- Returns:
- a new array containing the values from this array with the specified amount added
- Throws:
IllegalArgumentException- if the array and the amount have different currencies
-
minus
public CurrencyAmountArray minus(CurrencyAmountArray other)
Returns a new array containing the values from this array with the values from the other array subtracted.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.
- Parameters:
other- another array of multiple currency values.- Returns:
- a new array containing the values from this array with the values from the other array subtracted
- Throws:
IllegalArgumentException- if the arrays have different sizes or different currencies
-
minus
public CurrencyAmountArray minus(CurrencyAmount amount)
Returns a new array containing the values from this array with the specified amount subtracted.The amount is subtracted from each element in this array. The currency must be the same as the currency of this array.
- Parameters:
amount- the amount to subtract- Returns:
- a new array containing the values from this array with the specified amount subtracted
- Throws:
IllegalArgumentException- if the array and the amount have different currencies
-
meta
public static CurrencyAmountArray.Meta meta()
The meta-bean forCurrencyAmountArray.- Returns:
- the meta-bean, not null
-
metaBean
public CurrencyAmountArray.Meta metaBean()
- Specified by:
metaBeanin interfaceorg.joda.beans.Bean
-
getCurrency
public Currency getCurrency()
Gets the currency. All amounts have the same currency.- Returns:
- the value of the property, not null
-
getValues
public DoubleArray getValues()
Gets the values.- Returns:
- the value of the property, not null
-
-