public final class CurrencyScenarioArray extends Object implements ScenarioArray<CurrencyAmount>, ScenarioFxConvertible<CurrencyScenarioArray>, org.joda.beans.ImmutableBean, Serializable
This contains a list of amounts in a single currency, one amount for each scenario. The calculation runner is able to convert the currency of the values if required.
This class uses less memory than an instance based on a list of CurrencyAmount instances.
Internally, it stores the data using a single currency and a DoubleArray.
| Modifier and Type | Class and Description |
|---|---|
static class |
CurrencyScenarioArray.Meta
The meta-bean for
CurrencyScenarioArray. |
| Modifier and Type | Method and Description |
|---|---|
CurrencyScenarioArray |
convertedTo(Currency reportingCurrency,
ScenarioFxRateProvider fxRateProvider)
Converts this instance to an equivalent amount in the specified currency.
|
boolean |
equals(Object obj) |
CurrencyAmount |
get(int index)
Gets the value at the specified scenario index.
|
CurrencyAmountArray |
getAmounts()
Gets the currency amounts, one per scenario.
|
Currency |
getCurrency()
Gets the currency.
|
int |
getScenarioCount()
Gets the number of scenarios.
|
int |
hashCode() |
static CurrencyScenarioArray.Meta |
meta()
The meta-bean for
CurrencyScenarioArray. |
CurrencyScenarioArray.Meta |
metaBean() |
CurrencyScenarioArray |
minus(CurrencyAmount amount)
Returns a new array containing the values from this array with the specified amount subtracted.
|
CurrencyScenarioArray |
minus(CurrencyScenarioArray other)
Returns a new array containing the values from this array with the values from the other array subtracted.
|
static CurrencyScenarioArray |
of(CurrencyAmountArray amounts)
Obtains an instance from the specified currency and array of values.
|
static CurrencyScenarioArray |
of(Currency currency,
DoubleArray values)
Obtains an instance from the specified currency and array of values.
|
static CurrencyScenarioArray |
of(int size,
IntFunction<CurrencyAmount> amountFunction)
Obtains an instance using a function to create the entries.
|
static CurrencyScenarioArray |
of(List<CurrencyAmount> amounts)
Obtains an instance from the specified list of amounts.
|
CurrencyScenarioArray |
plus(CurrencyAmount amount)
Returns a new array containing the values from this array with the specified amount added.
|
CurrencyScenarioArray |
plus(CurrencyScenarioArray other)
Returns a new array containing the values from this array added to the values in the other array.
|
Stream<CurrencyAmount> |
stream()
Returns a stream of the values.
|
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitof, of, of, ofSingleValuepublic static CurrencyScenarioArray of(CurrencyAmountArray amounts)
amounts - the amounts, one for each scenariopublic static CurrencyScenarioArray of(Currency currency, DoubleArray values)
currency - the currency of the valuesvalues - the values, one for each scenariopublic static CurrencyScenarioArray of(List<CurrencyAmount> amounts)
All amounts must have the same currency.
amounts - the amounts, one for each scenarioIllegalArgumentException - if multiple currencies are foundpublic static CurrencyScenarioArray of(int size, IntFunction<CurrencyAmount> amountFunction)
The function is passed the scenario 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 oneamountFunction - the function used to obtain each amountIllegalArgumentException - is size is zero or lesspublic Currency getCurrency()
public int getScenarioCount()
ScenarioArraygetScenarioCount in interface ScenarioArray<CurrencyAmount>public CurrencyAmount get(int index)
ScenarioArrayget in interface ScenarioArray<CurrencyAmount>index - the zero-based index of the scenariopublic Stream<CurrencyAmount> stream()
ScenarioArrayThe stream will return the value for each scenario.
stream in interface ScenarioArray<CurrencyAmount>public CurrencyScenarioArray convertedTo(Currency reportingCurrency, ScenarioFxRateProvider fxRateProvider)
ScenarioFxConvertibleThe 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.
Any object that is not a currency amount will be left unchanged. The number of scenarios of this instance must match the number of scenarios of the specified provider.
convertedTo in interface ScenarioFxConvertible<CurrencyScenarioArray>reportingCurrency - the currency of the resultfxRateProvider - the multi-scenario provider of FX ratespublic CurrencyScenarioArray plus(CurrencyScenarioArray 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 CurrencyScenarioArray 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 CurrencyScenarioArray minus(CurrencyScenarioArray 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 CurrencyScenarioArray 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 CurrencyScenarioArray.Meta meta()
CurrencyScenarioArray.public CurrencyScenarioArray.Meta metaBean()
metaBean in interface org.joda.beans.Beanpublic CurrencyAmountArray getAmounts()
Copyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.