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