YieldSensitivityCalculator { public double calculateYield(final Annuity<? extends PaymentFixed> annuity, final double pv) { Validate.notNull(annuity, "annuity"); final Function1D<Double, Double> f = new Function1D<Double, Double>() { @Override public Double evaluate(final Double y) { return calculatePriceForYield(annuity, y) - pv; } }; final double[] range = BRACKETER.getBracketedPoints(f, 0.0, 0.2); return ROOT_FINDER.getRoot(f, range[0], range[1]); } private  YieldSensitivityCalculator(); static YieldSensitivityCalculator getInstance(); double calculateYield(final Annuity<? extends PaymentFixed> annuity, final double pv); double calculateYield(final AnnuityCouponFixed annuity, final double pv); double calculatePriceForYield(final Annuity<? extends PaymentFixed> annuity, final double yield); double calculatePriceForYield(final AnnuityCouponFixed annuity, final double yield); double calculateNthOrderSensitivity(final Annuity<? extends PaymentFixed> annuity, final double pv, final int order); double calculateNthOrderSensitivity(final AnnuityCouponFixed annuity, final double pv, final int order); double calculateNthOrderSensitivityFromYield(final Annuity<? extends PaymentFixed> annuity, final double yield, final int order); double calculateNthOrderSensitivityFromYield(final AnnuityCouponFixed annuity, final double yield, final int order);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullAnnuity1() { YSC.calculateYield((AnnuityCouponFixed) null, 1.0); }