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