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