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