@Test public void shouldTransformInput() { final LongToIntFunction function = a -> 123; final LongFunction<Long> keyFunction = Long::valueOf; final Cache<Long, Integer> cache = CacheBuilder.newBuilder().build(); final GuavaCacheBasedLongToIntFunctionMemoizer<Long> memoizer = new GuavaCacheBasedLongToIntFunctionMemoizer<>( cache, keyFunction, function); Assert.assertEquals("Memoized value does not match expectation", 123, 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);  }