@Test @SuppressWarnings(CompilerWarnings.UNCHECKED) public void shouldWrapExecutionExceptionInMemoizationException() throws ExecutionException { final IntFunction<Integer> keyFunction = Integer::valueOf; final Cache<Integer, Double> cache = Mockito.mock(Cache.class); given(cache.get(any(), any())).willThrow(ExecutionException.class); final GuavaCacheBasedIntToDoubleFunctionMemoizer<Integer> memoizer = new GuavaCacheBasedIntToDoubleFunctionMemoizer<>( cache, keyFunction, null); thrown.expect(MemoizationException.class); memoizer.applyAsDouble(789); }
@Override public double applyAsDouble(final int value) { final KEY key = keyFunction.apply(value); return get(key, givenKey -> Double.valueOf(function.applyAsDouble(value))).doubleValue(); }
GuavaCacheBasedIntToDoubleFunctionMemoizer extends AbstractGuavaCacheBasedMemoizer<KEY, Double> implements IntToDoubleFunction { @Override public double applyAsDouble(final int value) { final KEY key = keyFunction.apply(value); return get(key, givenKey -> Double.valueOf(function.applyAsDouble(value))).doubleValue(); } }
GuavaCacheBasedIntToDoubleFunctionMemoizer extends AbstractGuavaCacheBasedMemoizer<KEY, Double> implements IntToDoubleFunction { @Override public double applyAsDouble(final int value) { final KEY key = keyFunction.apply(value); return get(key, givenKey -> Double.valueOf(function.applyAsDouble(value))).doubleValue(); } GuavaCacheBasedIntToDoubleFunctionMemoizer(
            final Cache<KEY, Double> cache,
            final IntFunction<KEY> keyFunction,
            final IntToDoubleFunction function); }
GuavaCacheBasedIntToDoubleFunctionMemoizer extends AbstractGuavaCacheBasedMemoizer<KEY, Double> implements IntToDoubleFunction { @Override public double applyAsDouble(final int value) { final KEY key = keyFunction.apply(value); return get(key, givenKey -> Double.valueOf(function.applyAsDouble(value))).doubleValue(); } GuavaCacheBasedIntToDoubleFunctionMemoizer(
            final Cache<KEY, Double> cache,
            final IntFunction<KEY> keyFunction,
            final IntToDoubleFunction function); @Override double applyAsDouble(final int value); }
GuavaCacheBasedIntToDoubleFunctionMemoizer extends AbstractGuavaCacheBasedMemoizer<KEY, Double> implements IntToDoubleFunction { @Override public double applyAsDouble(final int value) { final KEY key = keyFunction.apply(value); return get(key, givenKey -> Double.valueOf(function.applyAsDouble(value))).doubleValue(); } GuavaCacheBasedIntToDoubleFunctionMemoizer(
            final Cache<KEY, Double> cache,
            final IntFunction<KEY> keyFunction,
            final IntToDoubleFunction function); @Override double applyAsDouble(final int value);  }