Class CurrencyScenarioArray

    • Method Detail

      • of

        public static CurrencyScenarioArray of​(CurrencyAmountArray 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 CurrencyScenarioArray of​(Currency currency,
                                               DoubleArray values)
        Obtains an instance from the specified currency and array of values.
        Parameters:
        currency - the currency of the values
        values - the values, one for each scenario
        Returns:
        an instance with the specified currency and values
      • of

        public static CurrencyScenarioArray of​(java.util.List<CurrencyAmount> amounts)
        Obtains an instance from the specified list of amounts.

        All amounts must have the same currency.

        Parameters:
        amounts - the amounts, one for each scenario
        Returns:
        an instance with the specified amounts
        Throws:
        java.lang.IllegalArgumentException - if multiple currencies are found
      • of

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

        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).

        Parameters:
        size - the number of elements, at least size one
        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
      • getCurrency

        public Currency getCurrency()
        Gets the currency.
        Returns:
        the currency
      • get

        public CurrencyAmount get​(int index)
        Description copied from interface: ScenarioArray
        Gets the value at the specified scenario index.
        Specified by:
        get in interface ScenarioArray<CurrencyAmount>
        Parameters:
        index - the zero-based index of the scenario
        Returns:
        the value at the specified index
      • 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
      • plus

        public CurrencyScenarioArray plus​(CurrencyScenarioArray 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:
        java.lang.IllegalArgumentException - if the arrays have different sizes or different currencies
      • plus

        public CurrencyScenarioArray 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:
        java.lang.IllegalArgumentException - if the array and the amount have different currencies
      • minus

        public CurrencyScenarioArray minus​(CurrencyScenarioArray 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:
        java.lang.IllegalArgumentException - if the arrays have different sizes or different currencies
      • minus

        public CurrencyScenarioArray 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:
        java.lang.IllegalArgumentException - if the array and the amount have different currencies
      • meta

        public static CurrencyScenarioArray.Meta meta()
        The meta-bean for CurrencyScenarioArray.
        Returns:
        the meta-bean, not null
      • getAmounts

        public CurrencyAmountArray getAmounts()
        Gets the 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