@Test @SuppressWarnings(CompilerWarnings.UNCHECKED) public void shouldWrapRuntimeExceptionInMemoizationException() { final LongFunction<String> keyFunction = a -> "key"; try (final Cache<String, String> cache = Mockito.mock(Cache.class)) { final JCacheBasedLongFunctionMemoizer<String, String> loader = new JCacheBasedLongFunctionMemoizer<>(cache, keyFunction, null); given(cache.invoke(any(), any())).willThrow(RuntimeException.class); thrown.expect(MemoizationException.class); loader.apply(123); } }
@Override public OUTPUT apply(final long value) { final KEY key = keyFunction.apply(value); return invoke(key, givenKey -> function.apply(value)); }
JCacheBasedLongFunctionMemoizer extends AbstractJCacheBasedMemoizer<KEY, OUTPUT> implements LongFunction<OUTPUT> { @Override public OUTPUT apply(final long value) { final KEY key = keyFunction.apply(value); return invoke(key, givenKey -> function.apply(value)); } }
JCacheBasedLongFunctionMemoizer extends AbstractJCacheBasedMemoizer<KEY, OUTPUT> implements LongFunction<OUTPUT> { @Override public OUTPUT apply(final long value) { final KEY key = keyFunction.apply(value); return invoke(key, givenKey -> function.apply(value)); } JCacheBasedLongFunctionMemoizer(
            final Cache<KEY, OUTPUT> cache,
            final LongFunction<KEY> keyFunction,
            final LongFunction<OUTPUT> function); }
JCacheBasedLongFunctionMemoizer extends AbstractJCacheBasedMemoizer<KEY, OUTPUT> implements LongFunction<OUTPUT> { @Override public OUTPUT apply(final long value) { final KEY key = keyFunction.apply(value); return invoke(key, givenKey -> function.apply(value)); } JCacheBasedLongFunctionMemoizer(
            final Cache<KEY, OUTPUT> cache,
            final LongFunction<KEY> keyFunction,
            final LongFunction<OUTPUT> function); @Override OUTPUT apply(final long value); }
JCacheBasedLongFunctionMemoizer extends AbstractJCacheBasedMemoizer<KEY, OUTPUT> implements LongFunction<OUTPUT> { @Override public OUTPUT apply(final long value) { final KEY key = keyFunction.apply(value); return invoke(key, givenKey -> function.apply(value)); } JCacheBasedLongFunctionMemoizer(
            final Cache<KEY, OUTPUT> cache,
            final LongFunction<KEY> keyFunction,
            final LongFunction<OUTPUT> function); @Override OUTPUT apply(final long value);  }