@Test public void shouldUseReturnFunctionResult() { final ConcurrentMap<String, Long> cache = new ConcurrentHashMap<>(); final ToLongFunction<String> function = input -> 123L; final Function<String, String> keyFunction = Function.identity(); final ConcurrentMapBasedToLongFunctionMemoizer<String, String> memoizer = new ConcurrentMapBasedToLongFunctionMemoizer<>( cache, keyFunction, function); Assert.assertEquals(123L, memoizer.applyAsLong("123")); }
@Override public long applyAsLong(final INPUT input) { final KEY key = keyFunction.apply(input); return computeIfAbsent(key, givenKey -> Long.valueOf(function.applyAsLong(input))) .longValue(); }
ConcurrentMapBasedToLongFunctionMemoizer extends ConcurrentMapBasedMemoizer<KEY, Long> implements ToLongFunction<INPUT> { @Override public long applyAsLong(final INPUT input) { final KEY key = keyFunction.apply(input); return computeIfAbsent(key, givenKey -> Long.valueOf(function.applyAsLong(input))) .longValue(); } }
ConcurrentMapBasedToLongFunctionMemoizer extends ConcurrentMapBasedMemoizer<KEY, Long> implements ToLongFunction<INPUT> { @Override public long applyAsLong(final INPUT input) { final KEY key = keyFunction.apply(input); return computeIfAbsent(key, givenKey -> Long.valueOf(function.applyAsLong(input))) .longValue(); } @SuppressWarnings(CompilerWarnings.NLS)  ConcurrentMapBasedToLongFunctionMemoizer(
            final ConcurrentMap<KEY, Long> cache,
            final Function<INPUT, KEY> keyFunction,
            final ToLongFunction<INPUT> function); }
ConcurrentMapBasedToLongFunctionMemoizer extends ConcurrentMapBasedMemoizer<KEY, Long> implements ToLongFunction<INPUT> { @Override public long applyAsLong(final INPUT input) { final KEY key = keyFunction.apply(input); return computeIfAbsent(key, givenKey -> Long.valueOf(function.applyAsLong(input))) .longValue(); } @SuppressWarnings(CompilerWarnings.NLS)  ConcurrentMapBasedToLongFunctionMemoizer(
            final ConcurrentMap<KEY, Long> cache,
            final Function<INPUT, KEY> keyFunction,
            final ToLongFunction<INPUT> function); @Override long applyAsLong(final INPUT input); }
ConcurrentMapBasedToLongFunctionMemoizer extends ConcurrentMapBasedMemoizer<KEY, Long> implements ToLongFunction<INPUT> { @Override public long applyAsLong(final INPUT input) { final KEY key = keyFunction.apply(input); return computeIfAbsent(key, givenKey -> Long.valueOf(function.applyAsLong(input))) .longValue(); } @SuppressWarnings(CompilerWarnings.NLS)  ConcurrentMapBasedToLongFunctionMemoizer(
            final ConcurrentMap<KEY, Long> cache,
            final Function<INPUT, KEY> keyFunction,
            final ToLongFunction<INPUT> function); @Override long applyAsLong(final INPUT input);  }