class CouponIborAverageFixingDatesDiscountingMethod {

  public MultipleCurrencyMulticurveSensitivity presentValueCurveSensitivity(final CouponIborAverageFixingDates coupon, final MulticurveProviderInterface multicurve) {
    ArgumentChecker.notNull(coupon, "Coupon");
    ArgumentChecker.notNull(multicurve, "Curves");
    final int nDates = coupon.getFixingPeriodEndTime().length;
    double forward = 0.;
    for (int i = 0; i < nDates; ++i) {
      final double forward1 = multicurve.getSimplyCompoundForwardRate(coupon.getIndex(), coupon.getFixingPeriodStartTime()[i], coupon.getFixingPeriodEndTime()[i],
          coupon.getFixingPeriodAccrualFactor()[i]);
      forward += coupon.getWeight()[i] * forward1;
    }
    forward += coupon.getAmountAccrued();
    final double df = multicurve.getDiscountFactor(coupon.getCurrency(), coupon.getPaymentTime());

    final double forwardBar = coupon.getNotional() * coupon.getPaymentYearFraction() * df;
    final double dfBar = coupon.getNotional() * coupon.getPaymentYearFraction() * forward;
    final double[] forwardBars = new double[nDates];
    for (int i = 0; i < nDates; ++i) {
      forwardBars[i] = coupon.getWeight()[i] * forwardBar;
    }
    final Map<String, List<DoublesPair>> mapDsc = new HashMap<>();
    final List<DoublesPair> listDiscounting = new ArrayList<>();
    listDiscounting.add(DoublesPair.of(coupon.getPaymentTime(), -coupon.getPaymentTime() * df * dfBar));
    mapDsc.put(multicurve.getName(coupon.getCurrency()), listDiscounting);

    final Map<String, List<ForwardSensitivity>> mapFwd = new HashMap<>();
    final List<ForwardSensitivity> listForward = new ArrayList<>();
    for (int i = 0; i < nDates; ++i) {
      listForward.add(new SimplyCompoundedForwardSensitivity(coupon.getFixingPeriodStartTime()[i], coupon.getFixingPeriodEndTime()[i], coupon.getFixingPeriodAccrualFactor()[i], forwardBars[i]));
    }
    mapFwd.put(multicurve.getName(coupon.getIndex()), listForward);
    return MultipleCurrencyMulticurveSensitivity.of(coupon.getCurrency(), MulticurveSensitivity.of(mapDsc, mapFwd));
  }

  private  CouponIborAverageFixingDatesDiscountingMethod();

}