class DispatchingRateComputationFn implements RateComputationFn<RateComputation> {

  @Override
  public double rate(
      RateComputation computation,
      LocalDate startDate,
      LocalDate endDate,
      RatesProvider provider) {

    double rate = rate0(computation, startDate, endDate, provider);
    if (rate != rate) {
      // this is most likely to occur during curve calibration
      throw new MathException("Unable to calculate rate, NaN found");
    }
    return rate;
  }

  public  DispatchingRateComputationFn(
      RateComputationFn<IborRateComputation> iborRateComputationFn,
      RateComputationFn<IborInterpolatedRateComputation> iborInterpolatedRateComputationFn,
      RateComputationFn<IborAveragedRateComputation> iborAveragedRateComputationFn,
      RateComputationFn<OvernightCompoundedRateComputation> overnightCompoundedRateComputationFn,
      RateComputationFn<OvernightCompoundedAnnualRateComputation> overnightCompundedAnnualRateComputationFn,
      RateComputationFn<OvernightAveragedRateComputation> overnightAveragedRateComputationFn,
      RateComputationFn<OvernightAveragedDailyRateComputation> overnightAveragedDailyRateComputationFn,
      RateComputationFn<InflationMonthlyRateComputation> inflationMonthlyRateComputationFn,
      RateComputationFn<InflationInterpolatedRateComputation> inflationInterpolatedRateComputationFn,
      RateComputationFn<InflationEndMonthRateComputation> inflationEndMonthRateComputationFn,
      RateComputationFn<InflationEndInterpolatedRateComputation> inflationEndInterpolatedRateComputationFn);

}