@Test public void shouldUseReturnOperatorResult() { final ConcurrentMap<Long, Long> cache = new ConcurrentHashMap<>(); final LongUnaryOperator operator = input -> input; final LongFunction<Long> keyFunction = Long::valueOf; final ConcurrentMapBasedLongUnaryOperatorMemoizer<Long> memoizer = new ConcurrentMapBasedLongUnaryOperatorMemoizer<>( cache, keyFunction, operator); Assert.assertEquals(123L, memoizer.applyAsLong(123L)); }
@Override public long applyAsLong(final long operand) { final KEY key = keyFunction.apply(operand); return computeIfAbsent(key, givenKey -> Long.valueOf(operator.applyAsLong(operand))) .intValue(); }
ConcurrentMapBasedLongUnaryOperatorMemoizer extends ConcurrentMapBasedMemoizer<KEY, Long> implements LongUnaryOperator { @Override public long applyAsLong(final long operand) { final KEY key = keyFunction.apply(operand); return computeIfAbsent(key, givenKey -> Long.valueOf(operator.applyAsLong(operand))) .intValue(); } }
ConcurrentMapBasedLongUnaryOperatorMemoizer extends ConcurrentMapBasedMemoizer<KEY, Long> implements LongUnaryOperator { @Override public long applyAsLong(final long operand) { final KEY key = keyFunction.apply(operand); return computeIfAbsent(key, givenKey -> Long.valueOf(operator.applyAsLong(operand))) .intValue(); } @SuppressWarnings(CompilerWarnings.NLS)  ConcurrentMapBasedLongUnaryOperatorMemoizer(
            final ConcurrentMap<KEY, Long> cache,
            final LongFunction<KEY> keyFunction,
            final LongUnaryOperator operator); }
ConcurrentMapBasedLongUnaryOperatorMemoizer extends ConcurrentMapBasedMemoizer<KEY, Long> implements LongUnaryOperator { @Override public long applyAsLong(final long operand) { final KEY key = keyFunction.apply(operand); return computeIfAbsent(key, givenKey -> Long.valueOf(operator.applyAsLong(operand))) .intValue(); } @SuppressWarnings(CompilerWarnings.NLS)  ConcurrentMapBasedLongUnaryOperatorMemoizer(
            final ConcurrentMap<KEY, Long> cache,
            final LongFunction<KEY> keyFunction,
            final LongUnaryOperator operator); @Override long applyAsLong(final long operand); }
ConcurrentMapBasedLongUnaryOperatorMemoizer extends ConcurrentMapBasedMemoizer<KEY, Long> implements LongUnaryOperator { @Override public long applyAsLong(final long operand) { final KEY key = keyFunction.apply(operand); return computeIfAbsent(key, givenKey -> Long.valueOf(operator.applyAsLong(operand))) .intValue(); } @SuppressWarnings(CompilerWarnings.NLS)  ConcurrentMapBasedLongUnaryOperatorMemoizer(
            final ConcurrentMap<KEY, Long> cache,
            final LongFunction<KEY> keyFunction,
            final LongUnaryOperator operator); @Override long applyAsLong(final long operand);  }