Class MultiCurrencyAmountArray

    • Method Detail

      • of

        public static MultiCurrencyAmountArray of​(MultiCurrencyAmount... amounts)
        Obtains an instance from the specified multi-currency amounts.
        Parameters:
        amounts - the amounts
        Returns:
        an instance with the specified amounts
      • of

        public static MultiCurrencyAmountArray of​(java.util.List<MultiCurrencyAmount> amounts)
        Obtains an instance from the specified multi-currency amounts.
        Parameters:
        amounts - the amounts
        Returns:
        an instance with the specified amounts
      • of

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

        The function is passed the index and returns the MultiCurrencyAmount for that index.

        Parameters:
        size - the number of elements, at least size one
        valueFunction - the function used to obtain each value
        Returns:
        an instance initialized using the function
        Throws:
        java.lang.IllegalArgumentException - is size is zero or less
      • of

        public static MultiCurrencyAmountArray of​(java.util.Map<Currency,​DoubleArray> values)
        Obtains an instance from a map of amounts.

        Each currency is associated with an array of amounts. All the arrays must have the same number of elements.

        If the map is empty the returned array will have a size of zero. To create an empty array with a non-zero size use one of the other of methods.

        Parameters:
        values - map of currencies to values
        Returns:
        an instance containing the values from the map
      • getCurrencies

        public java.util.Set<Currency> getCurrencies()
        Gets 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)
        Gets 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
      • size

        public int size()
        Gets the size of the array.
        Returns:
        the array size
      • get

        public MultiCurrencyAmount get​(int index)
        Gets the amount at the specified index.
        Parameters:
        index - the zero-based index to retrieve
        Returns:
        the amount at the specified index
      • stream

        public java.util.stream.Stream<MultiCurrencyAmount> stream()
        Returns a stream of the amounts.
        Returns:
        a stream of the amounts
      • convertedTo

        public CurrencyAmountArray convertedTo​(Currency resultCurrency,
                                               FxRateProvider fxRateProvider)
        Description copied from interface: FxConvertible
        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.

        Specified by:
        convertedTo in interface FxConvertible<CurrencyAmountArray>
        Parameters:
        resultCurrency - the currency of the result
        fxRateProvider - the provider of FX rates
        Returns:
        the converted instance, which should be expressed in the specified currency
      • plus

        public MultiCurrencyAmountArray plus​(MultiCurrencyAmountArray 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 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
      • plus

        public MultiCurrencyAmountArray plus​(MultiCurrencyAmount amount)
        Returns a new array containing the values from this array with the values from the amount added.

        The amount is added to each element in this array.

        Parameters:
        amount - the amount to add
        Returns:
        a new array containing the values from this array added to the values in the other array
      • minus

        public MultiCurrencyAmountArray minus​(MultiCurrencyAmountArray 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 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 with the values from the other array subtracted
        Throws:
        java.lang.IllegalArgumentException - if the arrays have different sizes
      • minus

        public MultiCurrencyAmountArray minus​(MultiCurrencyAmount amount)
        Returns a new array containing the values from this array with the values from the amount subtracted.

        The amount is subtracted from each element in this array.

        Parameters:
        amount - the amount to subtract
        Returns:
        a new array containing the values from this array with the values from the amount subtracted
      • total

        public static MultiCurrencyAmountArray total​(java.lang.Iterable<CurrencyAmountArray> arrays)
        Returns a multi currency amount 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
      • toMultiCurrencyAmountArray

        public static java.util.stream.Collector<CurrencyAmountArray,​?,​MultiCurrencyAmountArray> toMultiCurrencyAmountArray()
        Returns a collector which creates a multi currency amount array by combining a stream of currency amount arrays.

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

        Returns:
        the collector
      • getSize

        public int getSize()
        Gets the size of this array.
        Returns:
        the value of the property
      • getValues

        public com.google.common.collect.ImmutableSortedMap<Currency,​DoubleArray> getValues()
        Gets the currency values, keyed by currency.
        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