class ForexForwardPointsMethod {

  public MultipleCurrencyMulticurveSensitivity presentValueCurveSensitivity(final Forex fx, final MulticurveProviderInterface multicurves, final DoublesCurve forwardRates,
      final Pair<Currency, Currency> ccyPair) {
    final double payTime = fx.getPaymentTime();
    final double fwdRate = forwardRates.getYValue(payTime);
    final Currency ccy2;
    final double amount1;
    final double amount2;
    // Implementation note: The "if" is used to check in which order the fx is given with respect to the order of the forward rates.
    if (checkCurrency(fx, ccyPair)) { // Currency1 of fx is first currency in ccyPair
      ccy2 = fx.getCurrency2();
      amount1 = fx.getPaymentCurrency1().getAmount();
      amount2 = fx.getPaymentCurrency2().getAmount();
    } else {
      ccy2 = fx.getCurrency1();
      amount1 = fx.getPaymentCurrency2().getAmount();
      amount2 = fx.getPaymentCurrency1().getAmount();
    }
    final double df2 = multicurves.getDiscountFactor(ccy2, payTime);
    //    final double pv = df2 * (amount2 + amount1 * fwdRate);
    // Backward sweep
    final double pvBar = 1.0;
    final double df2Bar = (amount2 + amount1 * fwdRate) * pvBar;
    final DoublesPair s = DoublesPair.of(payTime, -payTime * df2 * df2Bar);
    final List<DoublesPair> list = new ArrayList<>();
    list.add(s);
    final Map<String, List<DoublesPair>> result = new HashMap<>();
    result.put(multicurves.getName(ccy2), list);
    return MultipleCurrencyMulticurveSensitivity.of(ccy2, MulticurveSensitivity.ofYieldDiscounting(result));
  }

  private  ForexForwardPointsMethod();

}