MulticurveProviderDiscount implements MulticurveProviderInterface, Serializable { public void setCurve(final Currency ccy, final YieldAndDiscountCurve curve) { ArgumentChecker.notNull(ccy, "currency"); ArgumentChecker.notNull(curve, "curve"); if (!_discountingCurves.containsKey(ccy)) { _discountingCurves.put(ccy, curve); setAllCurves(); } else { boolean curvesEqual = _discountingCurves.get(ccy).equals(curve); s_logger.debug("Two {} discounting curves for {}: {} {}", curvesEqual ? "equal" : "unequal", ccy.getCode(), curve, _discountingCurves.get(ccy)); if (!curvesEqual) { throw new IllegalArgumentException("Attempting to replace " + ccy.getCode() + " discounting curve with " + "different curve. existing: " + _discountingCurves.get(ccy) + ", new: " + curve); } } } MulticurveProviderDiscount();  MulticurveProviderDiscount(final FXMatrix fxMatrix);  MulticurveProviderDiscount(final Map<Currency, YieldAndDiscountCurve> discountingCurves, final Map<IborIndex, YieldAndDiscountCurve> forwardIborCurves,
      final Map<IndexON, YieldAndDiscountCurve> forwardONCurves, final FXMatrix fxMatrix);  MulticurveProviderDiscount(final MulticurveProviderDiscount market); @Override MulticurveProviderInterface getMulticurveProvider(); @Override MulticurveProviderDiscount copy(); @Override double[] parameterSensitivity(final String name, final List<DoublesPair> pointSensitivity); @Override double[] parameterForwardSensitivity(final String name, final List<ForwardSensitivity> pointSensitivity); @Override Integer getNumberOfParameters(final String name); @Override List<String> getUnderlyingCurvesNames(final String name); YieldAndDiscountCurve getCurve(final String name); List<Currency> getCurrencyForName(final String name); List<IborIndex> getIborIndexForName(final String name); List<IndexON> getOvernightIndexForName(final String name); @Override double getDiscountFactor(final Currency ccy, final Double time); @Override String getName(final Currency ccy); @Override Set<Currency> getCurrencies(); @Override double getInvestmentFactor(final IborIndex index, final double startTime, final double endTime, final double accrualFactor); @Override double getSimplyCompoundForwardRate(final IborIndex index, final double startTime, final double endTime, final double accrualFactor); @Override double getSimplyCompoundForwardRate(final IborIndex index, final double startTime, final double endTime); @Override double getAnnuallyCompoundForwardRate(final IborIndex index, final double startTime, final double endTime, final double accrualFactor); @Override double getAnnuallyCompoundForwardRate(final IborIndex index, final double startTime, final double endTime); @Override String getName(final IborIndex index); @Override Set<IborIndex> getIndexesIbor(); @Override double getInvestmentFactor(final IndexON index, final double startTime, final double endTime, final double accrualFactor); @Override double getSimplyCompoundForwardRate(final IndexON index, final double startTime, final double endTime, final double accrualFactor); @Override double getSimplyCompoundForwardRate(final IndexON index, final double startTime, final double endTime); @Override double getAnnuallyCompoundForwardRate(final IndexON index, final double startTime, final double endTime, final double accrualFactor); @Override double getAnnuallyCompoundForwardRate(final IndexON index, final double startTime, final double endTime); @Override String getName(final IndexON index); @Override Set<IndexON> getIndexesON(); YieldAndDiscountCurve getCurve(final Currency ccy); YieldAndDiscountCurve getCurve(final IborIndex index); YieldAndDiscountCurve getCurve(final IndexON index); @Override Set<String> getAllNames(); void setCurve(final Currency ccy, final YieldAndDiscountCurve curve); void setCurve(final IborIndex index, final YieldAndDiscountCurve curve); void setCurve(final IndexON index, final YieldAndDiscountCurve curve); void setAll(final MulticurveProviderDiscount other); void setForexMatrix(final FXMatrix fxMatrix); void replaceCurve(final Currency ccy, final YieldAndDiscountCurve curve); void replaceCurve(final IborIndex index, final YieldAndDiscountCurve curve); void replaceCurve(final IndexON index, final YieldAndDiscountCurve curve); void setOrReplaceCurve(final Currency ccy, final YieldAndDiscountCurve curve); void setOrReplaceCurve(final IborIndex index, final YieldAndDiscountCurve curve); void setOrReplaceCurve(final IndexON index, final YieldAndDiscountCurve curve); void removeCurve(final Currency ccy); @Override double getFxRate(final Currency ccy1, final Currency ccy2); @Override FXMatrix getFxRates(); Map<Currency, YieldAndDiscountCurve> getDiscountingCurves(); Map<IborIndex, YieldAndDiscountCurve> getForwardIborCurves(); Map<IndexON, YieldAndDiscountCurve> getForwardONCurves(); @Override Set<String> getAllCurveNames(); @Override String toString(); MulticurveProviderDiscount withDiscountFactor(final Currency ccy, final YieldAndDiscountCurve replacement); MulticurveProviderDiscount withForward(final IborIndex index, final YieldAndDiscountCurve replacement); MulticurveProviderDiscount withForward(final IndexON index, final YieldAndDiscountCurve replacement); @Override int hashCode(); @Override boolean equals(final Object obj);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testAddingDifferentDiscountingCurveWithSameCurrencyFails() { _provider.setCurve(Currency.USD, mockCurve("test")); _provider.setCurve(Currency.USD, mockCurve("test2")); }
@Test public void testAddingSameDiscountingCurveWithSameCurrencySucceeds() { YieldAndDiscountCurve test = mockCurve("test"); _provider.setCurve(Currency.USD, test); _provider.setCurve(Currency.USD, test); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testAddingDifferentForwardIborCurveWithSameIndexFails() { _provider.setCurve(IBOR_INDEX_1, mockCurve("test")); _provider.setCurve(IBOR_INDEX_1, mockCurve("test2")); }
@Test public void testAddingSameForwardIborCurveWithSameIndexSucceeds() { YieldAndDiscountCurve test = mockCurve("test"); _provider.setCurve(IBOR_INDEX_1, test); _provider.setCurve(IBOR_INDEX_1, test); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testAddingDifferentForwardONCurveWithSameIndexFails() { _provider.setCurve(INDEX_ON, mockCurve("test")); _provider.setCurve(INDEX_ON, mockCurve("test2")); }
@Test public void testAddingSameForwardONCurveWithSameIndexSucceeds() { YieldAndDiscountCurve test = mockCurve("test"); _provider.setCurve(INDEX_ON, test); _provider.setCurve(INDEX_ON, test); }