Class MultiCurrencyScenarioArray

    • Method Detail

      • of

        public static MultiCurrencyScenarioArray of​(MultiCurrencyAmountArray amounts)
        Obtains an instance from the specified currency and array of values.
        Parameters:
        amounts - the amounts, one for each scenario
        Returns:
        an instance with the specified currency and values
      • of

        public static MultiCurrencyScenarioArray of​(MultiCurrencyAmount... amounts)
        Returns an instance containing the values from the amounts.
        Parameters:
        amounts - the amounts, one for each scenario
        Returns:
        an instance containing the values from the list of amounts
      • of

        public static MultiCurrencyScenarioArray of​(List<MultiCurrencyAmount> amounts)
        Returns an instance containing the values from the list of amounts.
        Parameters:
        amounts - the amounts, one for each scenario
        Returns:
        an instance containing the values from the list of amounts
      • of

        public static MultiCurrencyScenarioArray of​(int size,
                                                    IntFunction<MultiCurrencyAmount> amountFunction)
        Obtains an instance using a function to create the entries.

        The function is passed the scenario index and returns the value for that index.

        Parameters:
        size - the number of elements
        amountFunction - the function used to obtain each amount
        Returns:
        an instance initialized using the function
        Throws:
        IllegalArgumentException - is size is zero or less
      • of

        public 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.
        Parameters:
        values - map of currencies to values
        Returns:
        an instance containing the values from the map
      • getCurrencies

        public Set<Currency> getCurrencies()
        Returns the set of currencies for which this object contains values.
        Returns:
        the set of currencies for which this object contains values
      • getValues

        public DoubleArray getValues​(Currency currency)
        Returns the values for the specified currency, throws an exception if there are no values for the currency.
        Parameters:
        currency - the currency for which values are required
        Returns:
        the values for the specified currency, throws an exception if there are none
        Throws:
        IllegalArgumentException - if there are no values for the currency
      • getScenarioCount

        public int getScenarioCount()
        Returns the number of currency values for each currency.
        Specified by:
        getScenarioCount in interface ScenarioArray<MultiCurrencyAmount>
        Returns:
        the number of currency values for each currency
      • convertedTo

        public CurrencyScenarioArray convertedTo​(Currency reportingCurrency,
                                                 ScenarioFxRateProvider fxRateProvider)
        Description copied from interface: ScenarioFxConvertible
        Converts 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.

        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.

        Specified by:
        convertedTo in interface ScenarioFxConvertible<CurrencyScenarioArray>
        Parameters:
        reportingCurrency - the currency of the result
        fxRateProvider - the multi-scenario provider of FX rates
        Returns:
        the converted instance, which should be expressed in the specified currency
      • total

        public static MultiCurrencyScenarioArray total​(Iterable<CurrencyScenarioArray> arrays)
        Returns a multi currency scenario array representing the total of the input arrays.

        If the input contains the same currency more than once, the amounts are added together.

        Parameters:
        arrays - the amount arrays
        Returns:
        the total amounts
      • toMultiCurrencyScenarioArray

        public static Collector<CurrencyScenarioArray,​?,​MultiCurrencyScenarioArray> toMultiCurrencyScenarioArray()
        Returns a collector which creates a multi currency scenario array by combining a stream of currency scenario arrays.

        The arrays in the stream must all have the same length.

        Returns:
        the collector
      • getAmounts

        public MultiCurrencyAmountArray getAmounts()
        Gets the multi-currency amounts, one per scenario.
        Returns:
        the value of the property, not null
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object