@Override public PointSensitivities build() { return new PointSensitivities( sensitivities); }
/** * Obtains an instance from a list of sensitivity entries. * * @param sensitivities the list of sensitivity entries * @return the sensitivities instance */ @SuppressWarnings("unchecked") public static PointSensitivities of(List<? extends PointSensitivity> sensitivities) { return new PointSensitivities((List<PointSensitivity>) sensitivities); }
/** * Combines this point sensitivities with another instance. * <p> * This returns a new sensitivity instance with a combined list of point sensitivities. * This instance is immutable and unaffected by this method. * The result may contain duplicate point sensitivities. * * @param other the other point sensitivities * @return a {@code PointSensitivities} based on this one, with the other instance added */ public PointSensitivities combinedWith(PointSensitivities other) { return new PointSensitivities(ImmutableList.<PointSensitivity>builder() .addAll(sensitivities) .addAll(other.sensitivities) .build()); }
@Override public PointSensitivities convertedTo(Currency resultCurrency, FxRateProvider rateProvider) { List<PointSensitivity> mutable = new ArrayList<>(); for (PointSensitivity sensi : sensitivities) { insert(mutable, sensi.convertedTo(resultCurrency, rateProvider)); } return new PointSensitivities(mutable); }
/** * Normalizes the point sensitivities by sorting and merging. * <p> * The list of sensitivities is sorted and then merged. * Any two entries that represent the same curve query are merged. * For example, if there are two point sensitivities that were created based on the same curve, * currency and fixing date, then the entries are combined, summing the sensitivity value. * <p> * The intention is that normalization occurs after gathering all the point sensitivities. * <p> * This instance is immutable and unaffected by this method. * * @return a {@code PointSensitivities} based on this one, with the sensitivities normalized */ public PointSensitivities normalized() { if (sensitivities.isEmpty()) { return this; } List<PointSensitivity> mutable = new ArrayList<>(); for (PointSensitivity sensi : sensitivities) { insert(mutable, sensi); } return new PointSensitivities(mutable); }