@Test public void shouldTransformInput() { final LongBinaryOperator function = (a, b) -> 123; final LongBinaryFunction<String> keyFunction = (a, b) -> "key"; final Cache<String, Long> cache = CacheBuilder.newBuilder().build(); final GuavaCacheBasedLongBinaryOperatorMemoizer<String> memoizer = new GuavaCacheBasedLongBinaryOperatorMemoizer<>( cache, keyFunction, function); Assert.assertEquals(123, memoizer.applyAsLong(123, 789)); }
@Override public long applyAsLong(final long left, final long right) { final KEY key = keyFunction.apply(left, right); return get(key, givenKey -> Long.valueOf(function.applyAsLong(left, right))).longValue(); }
GuavaCacheBasedLongBinaryOperatorMemoizer extends AbstractGuavaCacheBasedMemoizer<KEY, Long> implements LongBinaryOperator { @Override public long applyAsLong(final long left, final long right) { final KEY key = keyFunction.apply(left, right); return get(key, givenKey -> Long.valueOf(function.applyAsLong(left, right))).longValue(); } }
GuavaCacheBasedLongBinaryOperatorMemoizer extends AbstractGuavaCacheBasedMemoizer<KEY, Long> implements LongBinaryOperator { @Override public long applyAsLong(final long left, final long right) { final KEY key = keyFunction.apply(left, right); return get(key, givenKey -> Long.valueOf(function.applyAsLong(left, right))).longValue(); } GuavaCacheBasedLongBinaryOperatorMemoizer(
            final Cache<KEY, Long> cache,
            final LongBinaryFunction<KEY> keyFunction,
            final LongBinaryOperator function); }
GuavaCacheBasedLongBinaryOperatorMemoizer extends AbstractGuavaCacheBasedMemoizer<KEY, Long> implements LongBinaryOperator { @Override public long applyAsLong(final long left, final long right) { final KEY key = keyFunction.apply(left, right); return get(key, givenKey -> Long.valueOf(function.applyAsLong(left, right))).longValue(); } GuavaCacheBasedLongBinaryOperatorMemoizer(
            final Cache<KEY, Long> cache,
            final LongBinaryFunction<KEY> keyFunction,
            final LongBinaryOperator function); @Override long applyAsLong(final long left, final long right); }
GuavaCacheBasedLongBinaryOperatorMemoizer extends AbstractGuavaCacheBasedMemoizer<KEY, Long> implements LongBinaryOperator { @Override public long applyAsLong(final long left, final long right) { final KEY key = keyFunction.apply(left, right); return get(key, givenKey -> Long.valueOf(function.applyAsLong(left, right))).longValue(); } GuavaCacheBasedLongBinaryOperatorMemoizer(
            final Cache<KEY, Long> cache,
            final LongBinaryFunction<KEY> keyFunction,
            final LongBinaryOperator function); @Override long applyAsLong(final long left, final long right);  }