/** * Returns a new array containing the values from this array with the specified amount subtracted. * <p> * The amount is subtracted from each element in this array. * The currency must be the same as the currency of this array. * * @param amount the amount to subtract * @return a new array containing the values from this array with the specified amount subtracted * @throws IllegalArgumentException if the array and the amount have different currencies */ public CurrencyScenarioArray minus(CurrencyAmount amount) { return CurrencyScenarioArray.of(amounts.minus(amount)); }
/** * Returns a new array containing the values from this array with the values from the other array subtracted. * <p> * 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. * * @param other another array of multiple currency values. * @return a new array containing the values from this array with the values from the other array subtracted * @throws IllegalArgumentException if the arrays have different sizes or different currencies */ public CurrencyScenarioArray minus(CurrencyScenarioArray other) { return CurrencyScenarioArray.of(amounts.minus(other.amounts)); }
public void test_minus_currencyAmount() { DoubleArray values = DoubleArray.of(1, 2, 3); CurrencyAmountArray array = CurrencyAmountArray.of(GBP, values); CurrencyAmountArray result = array.minus(CurrencyAmount.of(GBP, 0.5)); assertThat(result).isEqualTo(CurrencyAmountArray.of(GBP, DoubleArray.of(0.5, 1.5, 2.5))); }