/** * Combines this parameter sensitivities with another instance. * * <p>This returns a new sensitivity instance with a combined list of parameter sensitivities. * This instance is immutable and unaffected by this method. The result may contain duplicate * parameter sensitivities. * * @param other the other parameter sensitivities * @return an instance based on this one, with the other instance added */ public CurveCurrencyParameterSensitivities combinedWith( CurveCurrencyParameterSensitivities other) { List<CurveCurrencyParameterSensitivity> mutable = new ArrayList<>(sensitivities); for (CurveCurrencyParameterSensitivity otherSens : other.sensitivities) { insert(mutable, otherSens); } return new CurveCurrencyParameterSensitivities(ImmutableList.copyOf(mutable)); }
/** * Obtains an instance from a list of sensitivity entries. * * @param sensitivities the list of sensitivity entries * @return the sensitivities instance */ public static CurveCurrencyParameterSensitivities of( List<? extends CurveCurrencyParameterSensitivity> sensitivities) { List<CurveCurrencyParameterSensitivity> mutable = new ArrayList<>(); for (CurveCurrencyParameterSensitivity otherSens : sensitivities) { insert(mutable, otherSens); } return new CurveCurrencyParameterSensitivities(ImmutableList.copyOf(mutable)); }
/** * Converts the sensitivities in this instance to an equivalent in the specified currency. * * <p>Any FX conversion that is required will use rates from the provider. * * @param resultCurrency the currency of the result * @param rateProvider the provider of FX rates * @return the sensitivity object expressed in terms of the result currency * @throws RuntimeException if no FX rate could be found */ @Override public CurveCurrencyParameterSensitivities convertedTo( Currency resultCurrency, FxRateProvider rateProvider) { List<CurveCurrencyParameterSensitivity> mutable = new ArrayList<>(); for (CurveCurrencyParameterSensitivity sens : sensitivities) { insert(mutable, sens.convertedTo(resultCurrency, rateProvider)); } return new CurveCurrencyParameterSensitivities(ImmutableList.copyOf(mutable)); }