GuavaCacheBasedToLongBiFunctionMemoizer extends AbstractGuavaCacheBasedMemoizer<KEY, Long> implements ToLongBiFunction<FIRST, SECOND> { @Override public long applyAsLong(final FIRST first, final SECOND second) { final KEY key = keyFunction.apply(first, second); return get(key, givenKey -> Long.valueOf(biFunction.applyAsLong(first, second))).longValue(); } GuavaCacheBasedToLongBiFunctionMemoizer(
            final Cache<KEY, Long> cache,
            final BiFunction<FIRST, SECOND, KEY> keyFunction,
            final ToLongBiFunction<FIRST, SECOND> biFunction); @Override long applyAsLong(final FIRST first, final SECOND second);  }
@Test public void shouldTransformInput() { final ToLongBiFunction<String, String> biFunction = (first, second) -> 123; final BiFunction<String, String, String> keyFunction = (first, second) -> second + first; final Cache<String, Long> cache = CacheBuilder.newBuilder().build(); final GuavaCacheBasedToLongBiFunctionMemoizer<String, String, String> memoizer = new GuavaCacheBasedToLongBiFunctionMemoizer<>( cache, keyFunction, biFunction); Assert.assertEquals("firstsecond", 123, memoizer.applyAsLong("first", "second")); }