ConcurrentMapBasedIntPredicateMemoizer extends ConcurrentMapBasedMemoizer<KEY, Boolean> implements IntPredicate { @Override public boolean test(final int value) { final KEY key = keyFunction.apply(value); return computeIfAbsent(key, givenKey -> Boolean.valueOf(predicate.test(value))).booleanValue(); } @SuppressWarnings(CompilerWarnings.NLS)  ConcurrentMapBasedIntPredicateMemoizer(
            final ConcurrentMap<KEY, Boolean> cache,
            final IntFunction<KEY> keyFunction,
            final IntPredicate predicate); @Override boolean test(final int value);  }
@Test public void shouldMemoizePredicateCall() { final ConcurrentMap<Integer, Boolean> cache = new ConcurrentHashMap<>(); final IntPredicate predicate = input -> true; final IntFunction<Integer> keyFunction = Integer::valueOf; final ConcurrentMapBasedIntPredicateMemoizer<Integer> memoizer = new ConcurrentMapBasedIntPredicateMemoizer<>( cache, keyFunction, predicate); Assert.assertTrue("Memoized value does not match expectations", memoizer.test(123)); }