ZSpreadCalculator { public double calculateZSpread(final Annuity<? extends Payment> annuity, final T curves, final double price) { ArgumentChecker.notNull(annuity, "annuity"); ArgumentChecker.notNull(curves, "curves"); final Function1D<Double, Double> f = new Function1D<Double, Double>() { @Override public Double evaluate(final Double y) { return calculatePriceForZSpread(annuity, curves, y) - price; } }; final double[] range = ROOT_BRACKETER.getBracketedPoints(f, 0.0, 1.2); return ROOT_FINDER.getRoot(f, range[0], range[1]); } ZSpreadCalculator(final InstrumentDerivativeVisitor<T, MultipleCurrencyAmount> pvCalculator,
      final InstrumentDerivativeVisitor<T, MultipleCurrencyMulticurveSensitivity> pvSensitivityCalculator); double calculateZSpread(final Annuity<? extends Payment> annuity, final T curves, final double price); double calculatePriceForZSpread(final Annuity<? extends Payment> annuity, final T curves, final double zSpread); double calculatePriceSensitivityToZSpread(final Annuity<? extends Payment> annuity, final T curves, final double zSpread); Map<String, List<DoublesPair>> calculatePriceSensitivityToCurve(final Annuity<? extends Payment> annuity, final T curves, final double zSpread); Map<String, List<DoublesPair>> calculateZSpreadSensitivityToCurve(final Annuity<? extends Payment> annuity, final T curves, final double zSpread);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullAnnuity4() { CALCULATOR.calculateZSpread(null, MULTI_CURVES, 0.04); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullCurves4() { CALCULATOR.calculateZSpread(PAYMENTS, null, 0.04); }