ZSpreadCalculator { public double calculatePriceSensitivityToZSpread(final Annuity<? extends Payment> annuity, final YieldCurveBundle curves, final double zSpread) { ArgumentChecker.notNull(annuity, "annuity"); ArgumentChecker.notNull(curves, "curves"); double sum = 0; final int n = annuity.getNumberOfPayments(); Payment payment; for (int i = 0; i < n; i++) { payment = annuity.getNthPayment(i); final double temp = payment.accept(PRESENT_VALUE_CALCULATOR, curves); final double time = payment.getPaymentTime(); sum -= time * temp * Math.exp(-zSpread * time); } return sum; } private  ZSpreadCalculator(); static ZSpreadCalculator getInstance(); double calculateZSpread(final Annuity<? extends Payment> annuity, final YieldCurveBundle curves, final double price); double calculatePriceForZSpread(final Annuity<? extends Payment> annuity, final YieldCurveBundle curves, final double zSpread); double calculatePriceSensitivityToZSpread(final Annuity<? extends Payment> annuity, final YieldCurveBundle curves, final double zSpread); Map<String, List<DoublesPair>> calculatePriceSensitivityToCurve(final Annuity<? extends Payment> annuity, final YieldCurveBundle curves, final double zSpread); Map<String, List<DoublesPair>> calculateZSpreadSensitivityToCurve(final Annuity<? extends Payment> annuity, final YieldCurveBundle curves, final double zSpread);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullAnnuity3() { CALCULATOR.calculatePriceSensitivityToZSpread(null, CURVES, 0.04); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullCurves3() { CALCULATOR.calculatePriceSensitivityToZSpread(PAYMENTS, null, 0.04); }