@Test @SuppressWarnings(CompilerWarnings.UNCHECKED) public void shouldWrapExecutionExceptionInMemoizationException() throws ExecutionException { final LongFunction<Long> keyFunction = Long::valueOf; final Cache<Long, Integer> cache = Mockito.mock(Cache.class); given(cache.get(any(), any())).willThrow(ExecutionException.class); final GuavaCacheBasedLongToIntFunctionMemoizer<Long> memoizer = new GuavaCacheBasedLongToIntFunctionMemoizer<>( cache, keyFunction, null); thrown.expect(MemoizationException.class); memoizer.applyAsInt(789); }
@Override public int applyAsInt(final long value) { final KEY key = keyFunction.apply(value); return get(key, givenKey -> Integer.valueOf(function.applyAsInt(value))).intValue(); }
GuavaCacheBasedLongToIntFunctionMemoizer extends AbstractGuavaCacheBasedMemoizer<KEY, Integer> implements LongToIntFunction { @Override public int applyAsInt(final long value) { final KEY key = keyFunction.apply(value); return get(key, givenKey -> Integer.valueOf(function.applyAsInt(value))).intValue(); } }
GuavaCacheBasedLongToIntFunctionMemoizer extends AbstractGuavaCacheBasedMemoizer<KEY, Integer> implements LongToIntFunction { @Override public int applyAsInt(final long value) { final KEY key = keyFunction.apply(value); return get(key, givenKey -> Integer.valueOf(function.applyAsInt(value))).intValue(); } GuavaCacheBasedLongToIntFunctionMemoizer(
            final Cache<KEY, Integer> cache,
            final LongFunction<KEY> keyFunction,
            final LongToIntFunction function); }
GuavaCacheBasedLongToIntFunctionMemoizer extends AbstractGuavaCacheBasedMemoizer<KEY, Integer> implements LongToIntFunction { @Override public int applyAsInt(final long value) { final KEY key = keyFunction.apply(value); return get(key, givenKey -> Integer.valueOf(function.applyAsInt(value))).intValue(); } GuavaCacheBasedLongToIntFunctionMemoizer(
            final Cache<KEY, Integer> cache,
            final LongFunction<KEY> keyFunction,
            final LongToIntFunction function); @Override int applyAsInt(final long value); }
GuavaCacheBasedLongToIntFunctionMemoizer extends AbstractGuavaCacheBasedMemoizer<KEY, Integer> implements LongToIntFunction { @Override public int applyAsInt(final long value) { final KEY key = keyFunction.apply(value); return get(key, givenKey -> Integer.valueOf(function.applyAsInt(value))).intValue(); } GuavaCacheBasedLongToIntFunctionMemoizer(
            final Cache<KEY, Integer> cache,
            final LongFunction<KEY> keyFunction,
            final LongToIntFunction function); @Override int applyAsInt(final long value);  }