@Test public void shouldMemoizeResult() { final DoublePredicate predicate = a -> true; final DoubleFunction<String> keyFunction = a -> "key"; final Cache<String, Boolean> cache = CacheBuilder.newBuilder().build(); final GuavaCacheBasedDoublePredicateMemoizer<String> memoizer = new GuavaCacheBasedDoublePredicateMemoizer<>( cache, keyFunction, predicate); Assert.assertTrue(memoizer.test(123.456D)); }
@Override public boolean test(final double input) { final KEY key = keyFunction.apply(input); return get(key, givenKey -> Boolean.valueOf(predicate.test(input))).booleanValue(); }
GuavaCacheBasedDoublePredicateMemoizer extends AbstractGuavaCacheBasedMemoizer<KEY, Boolean> implements DoublePredicate { @Override public boolean test(final double input) { final KEY key = keyFunction.apply(input); return get(key, givenKey -> Boolean.valueOf(predicate.test(input))).booleanValue(); } }
GuavaCacheBasedDoublePredicateMemoizer extends AbstractGuavaCacheBasedMemoizer<KEY, Boolean> implements DoublePredicate { @Override public boolean test(final double input) { final KEY key = keyFunction.apply(input); return get(key, givenKey -> Boolean.valueOf(predicate.test(input))).booleanValue(); } GuavaCacheBasedDoublePredicateMemoizer(
            final Cache<KEY, Boolean> cache,
            final DoubleFunction<KEY> keyFunction,
            final DoublePredicate predicate); }
GuavaCacheBasedDoublePredicateMemoizer extends AbstractGuavaCacheBasedMemoizer<KEY, Boolean> implements DoublePredicate { @Override public boolean test(final double input) { final KEY key = keyFunction.apply(input); return get(key, givenKey -> Boolean.valueOf(predicate.test(input))).booleanValue(); } GuavaCacheBasedDoublePredicateMemoizer(
            final Cache<KEY, Boolean> cache,
            final DoubleFunction<KEY> keyFunction,
            final DoublePredicate predicate); @Override boolean test(final double input); }
GuavaCacheBasedDoublePredicateMemoizer extends AbstractGuavaCacheBasedMemoizer<KEY, Boolean> implements DoublePredicate { @Override public boolean test(final double input) { final KEY key = keyFunction.apply(input); return get(key, givenKey -> Boolean.valueOf(predicate.test(input))).booleanValue(); } GuavaCacheBasedDoublePredicateMemoizer(
            final Cache<KEY, Boolean> cache,
            final DoubleFunction<KEY> keyFunction,
            final DoublePredicate predicate); @Override boolean test(final double input);  }