@Test public void shouldUseCallWrappedOperator() { final ConcurrentMap<String, Long> cache = new ConcurrentHashMap<>(); final LongBinaryFunction<String> keyFunction = (first, second) -> first + " " + second; final LongBinaryOperator operator = Mockito.mock(LongBinaryOperator.class); final ConcurrentMapBasedLongBinaryOperatorMemoizer<String> memoizer = new ConcurrentMapBasedLongBinaryOperatorMemoizer<>( cache, keyFunction, operator); memoizer.applyAsLong(123, 789); Mockito.verify(operator).applyAsLong(123, 789); }
@Override public long applyAsLong(final long left, final long right) { final KEY key = keyFunction.apply(left, right); return computeIfAbsent(key, givenKey -> Long.valueOf(operator.applyAsLong(left, right))) .longValue(); }
ConcurrentMapBasedLongBinaryOperatorMemoizer extends ConcurrentMapBasedMemoizer<KEY, Long> implements LongBinaryOperator { @Override public long applyAsLong(final long left, final long right) { final KEY key = keyFunction.apply(left, right); return computeIfAbsent(key, givenKey -> Long.valueOf(operator.applyAsLong(left, right))) .longValue(); } }
ConcurrentMapBasedLongBinaryOperatorMemoizer extends ConcurrentMapBasedMemoizer<KEY, Long> implements LongBinaryOperator { @Override public long applyAsLong(final long left, final long right) { final KEY key = keyFunction.apply(left, right); return computeIfAbsent(key, givenKey -> Long.valueOf(operator.applyAsLong(left, right))) .longValue(); } @SuppressWarnings(CompilerWarnings.NLS)  ConcurrentMapBasedLongBinaryOperatorMemoizer(
            final ConcurrentMap<KEY, Long> cache,
            final LongBinaryFunction<KEY> keyFunction,
            final LongBinaryOperator operator); }
ConcurrentMapBasedLongBinaryOperatorMemoizer extends ConcurrentMapBasedMemoizer<KEY, Long> implements LongBinaryOperator { @Override public long applyAsLong(final long left, final long right) { final KEY key = keyFunction.apply(left, right); return computeIfAbsent(key, givenKey -> Long.valueOf(operator.applyAsLong(left, right))) .longValue(); } @SuppressWarnings(CompilerWarnings.NLS)  ConcurrentMapBasedLongBinaryOperatorMemoizer(
            final ConcurrentMap<KEY, Long> cache,
            final LongBinaryFunction<KEY> keyFunction,
            final LongBinaryOperator operator); @Override long applyAsLong(final long left, final long right); }
ConcurrentMapBasedLongBinaryOperatorMemoizer extends ConcurrentMapBasedMemoizer<KEY, Long> implements LongBinaryOperator { @Override public long applyAsLong(final long left, final long right) { final KEY key = keyFunction.apply(left, right); return computeIfAbsent(key, givenKey -> Long.valueOf(operator.applyAsLong(left, right))) .longValue(); } @SuppressWarnings(CompilerWarnings.NLS)  ConcurrentMapBasedLongBinaryOperatorMemoizer(
            final ConcurrentMap<KEY, Long> cache,
            final LongBinaryFunction<KEY> keyFunction,
            final LongBinaryOperator operator); @Override long applyAsLong(final long left, final long right);  }