ConcurrentMapBasedLongFunctionMemoizer extends ConcurrentMapBasedMemoizer<KEY, OUTPUT> implements LongFunction<OUTPUT> { @Override public OUTPUT apply(final long value) { final KEY key = keyFunction.apply(value); return computeIfAbsent(key, givenKey -> function.apply(value)); } @SuppressWarnings(CompilerWarnings.NLS)  ConcurrentMapBasedLongFunctionMemoizer(
            final ConcurrentMap<KEY, OUTPUT> cache,
            final LongFunction<KEY> keyFunction,
            final LongFunction<OUTPUT> function); @Override OUTPUT apply(final long value);  }
@Test public void shouldMemoizeFunctionCall() { final ConcurrentMap<String, String> cache = new ConcurrentHashMap<>(); final LongFunction<String> function = input -> "output"; final LongFunction<String> keyFunction = input -> "key"; final ConcurrentMapBasedLongFunctionMemoizer<String, String> memoizer = new ConcurrentMapBasedLongFunctionMemoizer<>( cache, keyFunction, function); Assert.assertEquals("Memoized value does not match expectations", "output", memoizer.apply(123)); }