class DispatchingSwapPaymentEventPricer implements SwapPaymentEventPricer<SwapPaymentEvent> {

  @Override
  public PointSensitivityBuilder forecastValueSensitivity(SwapPaymentEvent paymentEvent, RatesProvider provider) {
    // dispatch by runtime type
    if (paymentEvent instanceof NotionalExchange) {
      return notionalExchangePricer.forecastValueSensitivity((NotionalExchange) paymentEvent, provider);
    } else if (paymentEvent instanceof FxResetNotionalExchange) {
      return fxResetNotionalExchangePricer.forecastValueSensitivity((FxResetNotionalExchange) paymentEvent, provider);
    } else {
      throw new IllegalArgumentException("Unknown PaymentEvent type: " + paymentEvent.getClass().getSimpleName());
    }
  }

  public  DispatchingSwapPaymentEventPricer(
      SwapPaymentEventPricer<NotionalExchange> notionalExchangePricer,
      SwapPaymentEventPricer<FxResetNotionalExchange> fxResetNotionalExchangePricer);

}