/** * Obtains an instance from the specified currency and array of values. * * @param amounts the amounts, one for each scenario * @return an instance with the specified currency and values */ public static CurrencyScenarioArray of(CurrencyAmountArray amounts) { return new CurrencyScenarioArray(amounts); }
@Override public CurrencyScenarioArray build() { return new CurrencyScenarioArray( amounts); }
/** * Obtains an instance from the specified list of amounts. * <p> * All amounts must have the same currency. * * @param amounts the amounts, one for each scenario * @return an instance with the specified amounts * @throws IllegalArgumentException if multiple currencies are found */ public static CurrencyScenarioArray of(List<CurrencyAmount> amounts) { return new CurrencyScenarioArray(CurrencyAmountArray.of(amounts)); }
/** * Obtains an instance from the specified currency and array of values. * * @param currency the currency of the values * @param values the values, one for each scenario * @return an instance with the specified currency and values */ public static CurrencyScenarioArray of(Currency currency, DoubleArray values) { return new CurrencyScenarioArray(CurrencyAmountArray.of(currency, values)); }
/** * Obtains an instance using a function to create the entries. * <p> * The function is passed the scenario index and returns the {@code CurrencyAmount} for that index. * <p> * In some cases it may be possible to specify the currency with a function providing a {@code double}. * To do this, use {@link DoubleArray#of(int, java.util.function.IntToDoubleFunction)} and * then call {@link #of(Currency, DoubleArray)}. * * @param size the number of elements, at least size one * @param amountFunction the function used to obtain each amount * @return an instance initialized using the function * @throws IllegalArgumentException is size is zero or less */ public static CurrencyScenarioArray of(int size, IntFunction<CurrencyAmount> amountFunction) { return new CurrencyScenarioArray(CurrencyAmountArray.of(size, amountFunction)); }