ResultConverterCache { @SuppressWarnings("unchecked") public <T> ResultConverter<? super T> getConverter(T value) { ResultConverter<?> converter = findConverterForType(value.getClass()); if (converter == null) { throw new IllegalArgumentException("No converter found for " + value.getClass()); } return (ResultConverter<? super T>) converter; } ResultConverterCache(); void registerConverter(ResultConverter<?> converter); @SuppressWarnings("unchecked") ResultConverter<? super T> getConverter(T value);  }
@Test public void get() { ResultConverterCache cache = new ResultConverterCache(); ResultConverter<?> converter = cache.getConverter(new Double(5.5)); assertNotNull(converter); assertTrue(converter instanceof DoubleConverter); converter = cache.getConverter(new DoubleMatrix1D(new double[0])); assertNotNull(converter); assertTrue(converter instanceof DoubleMatrix1DConverter); converter = cache.getConverter(new DoubleMatrix2D(new double[0][0])); assertNotNull(converter); assertTrue(converter instanceof DoubleMatrix2DConverter); converter = cache.getConverter(ImmutableLocalDateDoubleTimeSeries.EMPTY_SERIES); assertNotNull(converter); assertTrue(converter instanceof TimeSeriesConverter); converter = cache.getConverter(DiscountCurve.from(new ConstantDoublesCurve(2.5))); assertNotNull(converter); assertTrue(converter instanceof YieldAndDiscountCurveConverter); }