@Test @SuppressWarnings(CompilerWarnings.UNCHECKED) public void shouldWrapRuntimeExceptionInMemoizationException() { final BiFunction<String, String, String> keyfunction = hashCodeKeyFunction(); try (final Cache<String, Double> cache = Mockito.mock(Cache.class)) { final JCacheBasedToDoubleBiFunctionMemoizer<String, String, String> loader = new JCacheBasedToDoubleBiFunctionMemoizer<>( cache, keyfunction, null); given(cache.invoke(any(), any())).willThrow(RuntimeException.class); thrown.expect(MemoizationException.class); loader.applyAsDouble("first", "second"); } }
@Override public double applyAsDouble(final FIRST first, final SECOND second) { final KEY key = keyFunction.apply(first, second); return invoke(key, givenKey -> Double.valueOf(biFunction.applyAsDouble(first, second))).doubleValue(); }
JCacheBasedToDoubleBiFunctionMemoizer extends AbstractJCacheBasedMemoizer<KEY, Double> implements ToDoubleBiFunction<FIRST, SECOND> { @Override public double applyAsDouble(final FIRST first, final SECOND second) { final KEY key = keyFunction.apply(first, second); return invoke(key, givenKey -> Double.valueOf(biFunction.applyAsDouble(first, second))).doubleValue(); } }
JCacheBasedToDoubleBiFunctionMemoizer extends AbstractJCacheBasedMemoizer<KEY, Double> implements ToDoubleBiFunction<FIRST, SECOND> { @Override public double applyAsDouble(final FIRST first, final SECOND second) { final KEY key = keyFunction.apply(first, second); return invoke(key, givenKey -> Double.valueOf(biFunction.applyAsDouble(first, second))).doubleValue(); } JCacheBasedToDoubleBiFunctionMemoizer(
            final Cache<KEY, Double> cache,
            final BiFunction<FIRST, SECOND, KEY> keyFunction,
            final ToDoubleBiFunction<FIRST, SECOND> biFunction); }
JCacheBasedToDoubleBiFunctionMemoizer extends AbstractJCacheBasedMemoizer<KEY, Double> implements ToDoubleBiFunction<FIRST, SECOND> { @Override public double applyAsDouble(final FIRST first, final SECOND second) { final KEY key = keyFunction.apply(first, second); return invoke(key, givenKey -> Double.valueOf(biFunction.applyAsDouble(first, second))).doubleValue(); } JCacheBasedToDoubleBiFunctionMemoizer(
            final Cache<KEY, Double> cache,
            final BiFunction<FIRST, SECOND, KEY> keyFunction,
            final ToDoubleBiFunction<FIRST, SECOND> biFunction); @Override double applyAsDouble(final FIRST first, final SECOND second); }
JCacheBasedToDoubleBiFunctionMemoizer extends AbstractJCacheBasedMemoizer<KEY, Double> implements ToDoubleBiFunction<FIRST, SECOND> { @Override public double applyAsDouble(final FIRST first, final SECOND second) { final KEY key = keyFunction.apply(first, second); return invoke(key, givenKey -> Double.valueOf(biFunction.applyAsDouble(first, second))).doubleValue(); } JCacheBasedToDoubleBiFunctionMemoizer(
            final Cache<KEY, Double> cache,
            final BiFunction<FIRST, SECOND, KEY> keyFunction,
            final ToDoubleBiFunction<FIRST, SECOND> biFunction); @Override double applyAsDouble(final FIRST first, final SECOND second);  }