@Test public void shouldMemoizePredicate() { final DoublePredicate predicate = a -> true; final DoubleFunction<String> keyFunction = a -> "key"; try (final Cache<String, Boolean> cache = JCacheMemoize.createCache(DoublePredicate.class)) { final JCacheBasedDoublePredicateMemoizer<String> loader = new JCacheBasedDoublePredicateMemoizer<>(cache, keyFunction, predicate); Assert.assertTrue("Memoized value does not match expectation", loader.test(123.456D)); } }
@Override public boolean test(final double input) { final KEY key = keyFunction.apply(input); return invoke(key, givenKey -> Boolean.valueOf(predicate.test(input))).booleanValue(); }
JCacheBasedDoublePredicateMemoizer extends AbstractJCacheBasedMemoizer<KEY, Boolean> implements DoublePredicate { @Override public boolean test(final double input) { final KEY key = keyFunction.apply(input); return invoke(key, givenKey -> Boolean.valueOf(predicate.test(input))).booleanValue(); } }
JCacheBasedDoublePredicateMemoizer extends AbstractJCacheBasedMemoizer<KEY, Boolean> implements DoublePredicate { @Override public boolean test(final double input) { final KEY key = keyFunction.apply(input); return invoke(key, givenKey -> Boolean.valueOf(predicate.test(input))).booleanValue(); } JCacheBasedDoublePredicateMemoizer(
            final Cache<KEY, Boolean> cache,
            final DoubleFunction<KEY> keyFunction,
            final DoublePredicate predicate); }
JCacheBasedDoublePredicateMemoizer extends AbstractJCacheBasedMemoizer<KEY, Boolean> implements DoublePredicate { @Override public boolean test(final double input) { final KEY key = keyFunction.apply(input); return invoke(key, givenKey -> Boolean.valueOf(predicate.test(input))).booleanValue(); } JCacheBasedDoublePredicateMemoizer(
            final Cache<KEY, Boolean> cache,
            final DoubleFunction<KEY> keyFunction,
            final DoublePredicate predicate); @Override boolean test(final double input); }
JCacheBasedDoublePredicateMemoizer extends AbstractJCacheBasedMemoizer<KEY, Boolean> implements DoublePredicate { @Override public boolean test(final double input) { final KEY key = keyFunction.apply(input); return invoke(key, givenKey -> Boolean.valueOf(predicate.test(input))).booleanValue(); } JCacheBasedDoublePredicateMemoizer(
            final Cache<KEY, Boolean> cache,
            final DoubleFunction<KEY> keyFunction,
            final DoublePredicate predicate); @Override boolean test(final double input);  }