@Test @SuppressWarnings(CompilerWarnings.UNCHECKED) public void shouldUseCallWrappedFunction() { final ConcurrentMap<String, Integer> cache = new ConcurrentHashMap<>(); final ToIntFunction<String> function = Mockito.mock(ToIntFunction.class); final Function<String, String> keyFunction = Function.identity(); final ConcurrentMapBasedToIntFunctionMemoizer<String, String> memoizer = new ConcurrentMapBasedToIntFunctionMemoizer<>( cache, keyFunction, function); memoizer.applyAsInt("123"); Mockito.verify(function).applyAsInt("123"); }
@Override public int applyAsInt(final INPUT input) { final KEY key = keyFunction.apply(input); return computeIfAbsent(key, givenKey -> Integer.valueOf(function.applyAsInt(input))) .intValue(); }
ConcurrentMapBasedToIntFunctionMemoizer extends ConcurrentMapBasedMemoizer<KEY, Integer> implements ToIntFunction<INPUT> { @Override public int applyAsInt(final INPUT input) { final KEY key = keyFunction.apply(input); return computeIfAbsent(key, givenKey -> Integer.valueOf(function.applyAsInt(input))) .intValue(); } }
ConcurrentMapBasedToIntFunctionMemoizer extends ConcurrentMapBasedMemoizer<KEY, Integer> implements ToIntFunction<INPUT> { @Override public int applyAsInt(final INPUT input) { final KEY key = keyFunction.apply(input); return computeIfAbsent(key, givenKey -> Integer.valueOf(function.applyAsInt(input))) .intValue(); } @SuppressWarnings(CompilerWarnings.NLS)  ConcurrentMapBasedToIntFunctionMemoizer(
            final ConcurrentMap<KEY, Integer> cache,
            final Function<INPUT, KEY> keyFunction,
            final ToIntFunction<INPUT> function); }
ConcurrentMapBasedToIntFunctionMemoizer extends ConcurrentMapBasedMemoizer<KEY, Integer> implements ToIntFunction<INPUT> { @Override public int applyAsInt(final INPUT input) { final KEY key = keyFunction.apply(input); return computeIfAbsent(key, givenKey -> Integer.valueOf(function.applyAsInt(input))) .intValue(); } @SuppressWarnings(CompilerWarnings.NLS)  ConcurrentMapBasedToIntFunctionMemoizer(
            final ConcurrentMap<KEY, Integer> cache,
            final Function<INPUT, KEY> keyFunction,
            final ToIntFunction<INPUT> function); @Override int applyAsInt(final INPUT input); }
ConcurrentMapBasedToIntFunctionMemoizer extends ConcurrentMapBasedMemoizer<KEY, Integer> implements ToIntFunction<INPUT> { @Override public int applyAsInt(final INPUT input) { final KEY key = keyFunction.apply(input); return computeIfAbsent(key, givenKey -> Integer.valueOf(function.applyAsInt(input))) .intValue(); } @SuppressWarnings(CompilerWarnings.NLS)  ConcurrentMapBasedToIntFunctionMemoizer(
            final ConcurrentMap<KEY, Integer> cache,
            final Function<INPUT, KEY> keyFunction,
            final ToIntFunction<INPUT> function); @Override int applyAsInt(final INPUT input);  }