@Override
 public MultipleCurrencyCurveSensitivityMarket visitCouponOIS(
     final CouponOIS payment, final IMarketBundle market) {
   return METHOD_CPN_ON.presentValueMarketSensitivity(payment, market);
 }
/**
 * Calculator of the present value curve sensitivity as multiple currency interest rate curve
 * sensitivity.
 */
public final class PresentValueCurveSensitivityMarketCalculator
    extends AbstractInstrumentDerivativeVisitor<
        IMarketBundle, MultipleCurrencyCurveSensitivityMarket> {

  /** The unique instance of the calculator. */
  private static final PresentValueCurveSensitivityMarketCalculator INSTANCE =
      new PresentValueCurveSensitivityMarketCalculator();

  /**
   * Gets the calculator instance.
   *
   * @return The calculator.
   */
  public static PresentValueCurveSensitivityMarketCalculator getInstance() {
    return INSTANCE;
  }

  /** Constructor. */
  private PresentValueCurveSensitivityMarketCalculator() {}

  /** The methods used by the different instruments. */
  private static final CouponFixedDiscountingMarketMethod METHOD_CPN_FIXED =
      CouponFixedDiscountingMarketMethod.getInstance();

  private static final CouponIborDiscountingMarketMethod METHOD_CPN_IBOR =
      CouponIborDiscountingMarketMethod.getInstance();
  private static final CouponOISDiscountingMarketMethod METHOD_CPN_ON =
      CouponOISDiscountingMarketMethod.getInstance();

  // -----     Payment/Coupon     ------

  @Override
  public MultipleCurrencyCurveSensitivityMarket visitCouponFixed(
      final CouponFixed payment, final IMarketBundle market) {
    return METHOD_CPN_FIXED.presentValueMarketSensitivity(payment, market);
  }

  @Override
  public MultipleCurrencyCurveSensitivityMarket visitCouponIbor(
      final CouponIbor payment, final IMarketBundle market) {
    return METHOD_CPN_IBOR.presentValueMarketSensitivity(payment, market);
  }

  @Override
  public MultipleCurrencyCurveSensitivityMarket visitCouponOIS(
      final CouponOIS payment, final IMarketBundle market) {
    return METHOD_CPN_ON.presentValueMarketSensitivity(payment, market);
  }

  // -----     Annuity     ------

  @Override
  public MultipleCurrencyCurveSensitivityMarket visitGenericAnnuity(
      final Annuity<? extends Payment> annuity, final IMarketBundle market) {
    ArgumentChecker.notNull(annuity, "Annuity");
    ArgumentChecker.notNull(market, "Market");
    MultipleCurrencyCurveSensitivityMarket cs = visit(annuity.getNthPayment(0), market);
    for (int loopp = 1; loopp < annuity.getNumberOfPayments(); loopp++) {
      cs = cs.plus(visit(annuity.getNthPayment(loopp), market));
    }
    return cs;
  }

  @Override
  public MultipleCurrencyCurveSensitivityMarket visitFixedCouponAnnuity(
      final AnnuityCouponFixed annuity, final IMarketBundle market) {
    return visitGenericAnnuity(annuity, market);
  }

  // -----     Swap     ------

  @Override
  public MultipleCurrencyCurveSensitivityMarket visitSwap(
      final Swap<?, ?> swap, final IMarketBundle market) {
    final MultipleCurrencyCurveSensitivityMarket sensitivity1 = visit(swap.getFirstLeg(), market);
    final MultipleCurrencyCurveSensitivityMarket sensitivity2 = visit(swap.getSecondLeg(), market);
    return sensitivity1.plus(sensitivity2);
  }

  @Override
  public MultipleCurrencyCurveSensitivityMarket visitFixedCouponSwap(
      final SwapFixedCoupon<?> swap, final IMarketBundle market) {
    return visitSwap(swap, market);
  }
}