GuavaCacheBasedBiConsumerMemoizer extends AbstractGuavaCacheBasedMemoizer<KEY, KEY> implements BiConsumer<FIRST, SECOND> { @Override public void accept(final FIRST first, final SECOND second) { final KEY key = keyFunction.apply(first, second); get(key, givenKey -> { biConsumer.accept(first, second); return givenKey; }); } GuavaCacheBasedBiConsumerMemoizer(
            final Cache<KEY, KEY> cache,
            final BiFunction<FIRST, SECOND, KEY> keyFunction,
            final BiConsumer<FIRST, SECOND> biConsumer); @Override void accept(final FIRST first, final SECOND second);  }
@Test @SuppressWarnings(CompilerWarnings.UNCHECKED) public void shouldAcceptInput() { final BiConsumer<String, String> biConsumer = Mockito.mock(BiConsumer.class); final BiFunction<String, String, String> keyFunction = (first, second) -> second + first; final Cache<String, String> cache = CacheBuilder.newBuilder().build(); final GuavaCacheBasedBiConsumerMemoizer<String, String, String> memoizer = new GuavaCacheBasedBiConsumerMemoizer<>( cache, keyFunction, biConsumer); memoizer.accept("first", "second"); Mockito.verify(biConsumer).accept("first", "second"); }