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​(java.util.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,
                                                    java.util.function.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:
        java.lang.IllegalArgumentException - is size is zero or less
      • of

        public static MultiCurrencyScenarioArray of​(java.util.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 java.util.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:
        java.lang.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
      • get

        public MultiCurrencyAmount get​(int index)
        Returns a 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.

        Specified by:
        get in interface ScenarioArray<MultiCurrencyAmount>
        Parameters:
        index - the index that should be returned
        Returns:
        a multi currency amount containing the currency values at the specified index
        Throws:
        java.lang.IndexOutOfBoundsException - if the index is invalid
      • 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​(java.lang.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 java.util.stream.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
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object