public final class MultiCurrencyScenarioArray extends Object implements ScenarioArray<MultiCurrencyAmount>, ScenarioFxConvertible<CurrencyScenarioArray>, org.joda.beans.ImmutableBean, Serializable
This contains a list of amounts in a multiple currencies, 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 MultiCurrencyAmount
instances.
Internally, it stores the data using a map of currency to DoubleArray
.
Modifier and Type | Class and Description |
---|---|
static class |
MultiCurrencyScenarioArray.Meta
The meta-bean for
MultiCurrencyScenarioArray . |
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) |
MultiCurrencyAmount |
get(int index)
Returns a
MultiCurrencyAmount at the specified index. |
MultiCurrencyAmountArray |
getAmounts()
Gets the multi-currency amounts, one per scenario.
|
Set<Currency> |
getCurrencies()
Returns the set of currencies for which this object contains values.
|
int |
getScenarioCount()
Returns the number of currency values for each currency.
|
DoubleArray |
getValues(Currency currency)
Returns the values for the specified currency, throws an exception if there are no values for the currency.
|
int |
hashCode() |
static MultiCurrencyScenarioArray.Meta |
meta()
The meta-bean for
MultiCurrencyScenarioArray . |
MultiCurrencyScenarioArray.Meta |
metaBean() |
static MultiCurrencyScenarioArray |
of(int size,
IntFunction<MultiCurrencyAmount> amountFunction)
Obtains an instance using a function to create the entries.
|
static MultiCurrencyScenarioArray |
of(List<MultiCurrencyAmount> amounts)
Returns an instance containing the values from the list of amounts.
|
static MultiCurrencyScenarioArray |
of(Map<Currency,DoubleArray> values)
Returns an instance containing the values from a map of amounts with the same number of elements in each array.
|
static MultiCurrencyScenarioArray |
of(MultiCurrencyAmount... amounts)
Returns an instance containing the values from the amounts.
|
static MultiCurrencyScenarioArray |
of(MultiCurrencyAmountArray amounts)
Obtains an instance from the specified currency and array of values.
|
Stream<MultiCurrencyAmount> |
stream()
Returns a stream of
MultiCurrencyAmount instances containing the values from this object. |
static Collector<CurrencyScenarioArray,?,MultiCurrencyScenarioArray> |
toMultiCurrencyScenarioArray()
Returns a collector which creates a multi currency scenario array by combining a stream of
currency scenario arrays.
|
String |
toString() |
static MultiCurrencyScenarioArray |
total(Iterable<CurrencyScenarioArray> arrays)
Returns a multi currency scenario array representing the total of the input arrays.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
of, of, of, ofSingleValue
public static MultiCurrencyScenarioArray of(MultiCurrencyAmountArray amounts)
amounts
- the amounts, one for each scenariopublic static MultiCurrencyScenarioArray of(MultiCurrencyAmount... amounts)
amounts
- the amounts, one for each scenariopublic static MultiCurrencyScenarioArray of(List<MultiCurrencyAmount> amounts)
amounts
- the amounts, one for each scenariopublic static MultiCurrencyScenarioArray of(int size, IntFunction<MultiCurrencyAmount> amountFunction)
The function is passed the scenario index and returns the value for that index.
size
- the number of elementsamountFunction
- the function used to obtain each amountIllegalArgumentException
- is size is zero or lesspublic static MultiCurrencyScenarioArray of(Map<Currency,DoubleArray> values)
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 getScenarioCount()
getScenarioCount
in interface ScenarioArray<MultiCurrencyAmount>
public MultiCurrencyAmount get(int index)
MultiCurrencyAmount
at the specified index.
This method is not very efficient for large sizes as a new object must be created at each index.
Consider using getValues(Currency)
instead.
get
in interface ScenarioArray<MultiCurrencyAmount>
index
- the index that should be returnedIndexOutOfBoundsException
- if the index is invalidpublic Stream<MultiCurrencyAmount> stream()
MultiCurrencyAmount
instances containing the values from this object.
This method is not very efficient for large sizes as a new object must be created for each value.
Consider using getValues(Currency)
instead.
stream
in interface ScenarioArray<MultiCurrencyAmount>
public CurrencyScenarioArray convertedTo(Currency reportingCurrency, ScenarioFxRateProvider fxRateProvider)
ScenarioFxConvertible
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.
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 static MultiCurrencyScenarioArray total(Iterable<CurrencyScenarioArray> arrays)
If the input contains the same currency more than once, the amounts are added together.
arrays
- the amount arrayspublic static Collector<CurrencyScenarioArray,?,MultiCurrencyScenarioArray> toMultiCurrencyScenarioArray()
The arrays in the stream must all have the same length.
public static MultiCurrencyScenarioArray.Meta meta()
MultiCurrencyScenarioArray
.public MultiCurrencyScenarioArray.Meta metaBean()
metaBean
in interface org.joda.beans.Bean
public MultiCurrencyAmountArray getAmounts()
Copyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.