DayPeriodPreCalculatedDiscountCurve extends DiscountCurve { @Override public double getDiscountFactor(final double t) { if (_preCalculatedDiscountFactors == null) { return super.getDiscountFactor(t); } final long nDaysLong = Math.round(t * _daysPerYear); if (nDaysLong > Integer.MAX_VALUE) { return super.getDiscountFactor(t); } final int nDays = (int) nDaysLong; if (nDays > _preCalculatedDiscountFactors.length) { return super.getDiscountFactor(t); } return _preCalculatedDiscountFactors[nDays]; } DayPeriodPreCalculatedDiscountCurve(final String name, final DoublesCurve discountFactorCurve);  DayPeriodPreCalculatedDiscountCurve(final String name, final DoublesCurve discountFactorCurve, final double daysPerYear); void preCalculateDiscountFactors(final int numYears); @Override double getDiscountFactor(final double t); boolean isPreCalculated(); boolean isPreCalculated(final int nDaysForward);  }
@Test(groups = TestGroup.UNIT) public void testGetDiscountFactor() throws Exception { final DayPeriodPreCalculatedDiscountCurve curve = new DayPeriodPreCalculatedDiscountCurve("test", DOUBLES_CURVE, DateUtils.DAYS_PER_YEAR); curve.preCalculateDiscountFactors(15); for (int i = 0; i < x[x.length - 1]; i++) { final double t = i / DateUtils.DAYS_PER_YEAR; Assert.assertEquals(EXISTING_CURVE.getDiscountFactor(t), curve.getDiscountFactor(t), TOLERANCE); } }