@Test public void shouldMemoizeBiFunction() { final LongUnaryOperator function = first -> 123; final LongFunction<String> keyfunction = a -> "key"; try (final Cache<String, Long> cache = JCacheMemoize.createCache(ToDoubleBiFunction.class)) { final JCacheBasedLongUnaryOperatorMemoizer<String> loader = new JCacheBasedLongUnaryOperatorMemoizer<>( cache, keyfunction, function); Assert.assertEquals("Memoized value does not match expectation", 123, loader.applyAsLong(123)); } }
@Override public long applyAsLong(final long value) { final KEY key = keyFunction.apply(value); return invoke(key, givenKey -> Long.valueOf(biFunction.applyAsLong(value))).longValue(); }
JCacheBasedLongUnaryOperatorMemoizer extends AbstractJCacheBasedMemoizer<KEY, Long> implements LongUnaryOperator { @Override public long applyAsLong(final long value) { final KEY key = keyFunction.apply(value); return invoke(key, givenKey -> Long.valueOf(biFunction.applyAsLong(value))).longValue(); } }
JCacheBasedLongUnaryOperatorMemoizer extends AbstractJCacheBasedMemoizer<KEY, Long> implements LongUnaryOperator { @Override public long applyAsLong(final long value) { final KEY key = keyFunction.apply(value); return invoke(key, givenKey -> Long.valueOf(biFunction.applyAsLong(value))).longValue(); } JCacheBasedLongUnaryOperatorMemoizer(
            final Cache<KEY, Long> cache,
            final LongFunction<KEY> keyFunction,
            final LongUnaryOperator biFunction); }
JCacheBasedLongUnaryOperatorMemoizer extends AbstractJCacheBasedMemoizer<KEY, Long> implements LongUnaryOperator { @Override public long applyAsLong(final long value) { final KEY key = keyFunction.apply(value); return invoke(key, givenKey -> Long.valueOf(biFunction.applyAsLong(value))).longValue(); } JCacheBasedLongUnaryOperatorMemoizer(
            final Cache<KEY, Long> cache,
            final LongFunction<KEY> keyFunction,
            final LongUnaryOperator biFunction); @Override long applyAsLong(final long value); }
JCacheBasedLongUnaryOperatorMemoizer extends AbstractJCacheBasedMemoizer<KEY, Long> implements LongUnaryOperator { @Override public long applyAsLong(final long value) { final KEY key = keyFunction.apply(value); return invoke(key, givenKey -> Long.valueOf(biFunction.applyAsLong(value))).longValue(); } JCacheBasedLongUnaryOperatorMemoizer(
            final Cache<KEY, Long> cache,
            final LongFunction<KEY> keyFunction,
            final LongUnaryOperator biFunction); @Override long applyAsLong(final long value);  }