YieldAndDiscountCurveConverter implements ResultConverter<YieldAndDiscountCurve> { @Override public Map<String, Double> convert(String valueName, YieldAndDiscountCurve value) { if (!(value instanceof YieldCurve)) { throw new IllegalArgumentException("Can only handle YieldCurve"); } Map<String, Double> returnValue = new HashMap<String, Double>(); for (Double x : ((YieldCurve) value).getCurve().getXData()) { Double y = ((YieldCurve) value).getCurve().getYValue(x); returnValue.put(valueName + "[" + x + "]", y); } return returnValue; }  @Override Map<String, Double> convert(String valueName, YieldAndDiscountCurve value); @Override Class<?> getConvertedClass();  }
@Test public void convertNonEmpty() { final Map<Double, Double> map = new HashMap<Double, Double>(); map.put(1., 0.03); map.put(2., 0.04); map.put(3.5, 0.05); Map<String, Double> expected = new HashMap<String, Double>(); expected.put("Foo[1.0]", 0.03); expected.put("Foo[2.0]", 0.04); expected.put("Foo[3.5]", 0.05); Map<String, Double> actual = _converter.convert("Foo", YieldCurve.from(InterpolatedDoublesCurve.from(map, Interpolator1DFactory.getInterpolator("Linear")))); assertEquals(expected, actual); }