@Override
public Double visitSwap(final Swap<?, ?> swap, final InflationProviderInterface inflation) {
ArgumentChecker.notNull(inflation, "Market");
ArgumentChecker.notNull(swap, "Swap");
if (swap.getFirstLeg().getNumberOfPayments() == 1 && swap.getFirstLeg().getNthPayment(0) instanceof CouponFixedCompounding) {
final CouponFixedCompounding cpn = (CouponFixedCompounding) swap.getFirstLeg().getNthPayment(0);
final double pvInflationLeg = swap.getSecondLeg().accept(PVIC, inflation).getAmount(swap.getSecondLeg().getCurrency());
final double discountFactor = inflation.getDiscountFactor(swap.getFirstLeg().getCurrency(), cpn.getPaymentTime());
final double tenor = cpn.getPaymentAccrualFactors().length;
final double notional = ((CouponInflation) swap.getSecondLeg().getNthPayment(0)).getNotional();
return Math.pow(pvInflationLeg / discountFactor / notional + 1, 1 / tenor) - 1 - cpn.getRate();
}
final MulticurveProviderInterface multicurves = inflation.getMulticurveProvider();
return -multicurves.getFxRates().convert(swap.accept(PVMC, multicurves), swap.getFirstLeg().getCurrency()).getAmount() / swap.getFirstLeg().accept(PVMQSC, multicurves);
}