@Test public void shouldUseReturnFunctionResult() { final ConcurrentMap<Long, Double> cache = new ConcurrentHashMap<>(); final LongToDoubleFunction function = input -> 123; final LongFunction<Long> keyFunction = Long::valueOf; final ConcurrentMapBasedLongToDoubleFunctionMemoizer<Long> memoizer = new ConcurrentMapBasedLongToDoubleFunctionMemoizer<>( cache, keyFunction, function); Assert.assertEquals(123D, memoizer.applyAsDouble(123), 0.0D); }
@Override public double applyAsDouble(final long value) { final KEY key = keyFunction.apply(value); return computeIfAbsent(key, givenKey -> Double.valueOf(function.applyAsDouble(value))) .doubleValue(); }
ConcurrentMapBasedLongToDoubleFunctionMemoizer extends ConcurrentMapBasedMemoizer<KEY, Double> implements LongToDoubleFunction { @Override public double applyAsDouble(final long value) { final KEY key = keyFunction.apply(value); return computeIfAbsent(key, givenKey -> Double.valueOf(function.applyAsDouble(value))) .doubleValue(); } }
ConcurrentMapBasedLongToDoubleFunctionMemoizer extends ConcurrentMapBasedMemoizer<KEY, Double> implements LongToDoubleFunction { @Override public double applyAsDouble(final long value) { final KEY key = keyFunction.apply(value); return computeIfAbsent(key, givenKey -> Double.valueOf(function.applyAsDouble(value))) .doubleValue(); } @SuppressWarnings(CompilerWarnings.NLS)  ConcurrentMapBasedLongToDoubleFunctionMemoizer(
            final ConcurrentMap<KEY, Double> cache,
            final LongFunction<KEY> keyFunction,
            final LongToDoubleFunction function); }
ConcurrentMapBasedLongToDoubleFunctionMemoizer extends ConcurrentMapBasedMemoizer<KEY, Double> implements LongToDoubleFunction { @Override public double applyAsDouble(final long value) { final KEY key = keyFunction.apply(value); return computeIfAbsent(key, givenKey -> Double.valueOf(function.applyAsDouble(value))) .doubleValue(); } @SuppressWarnings(CompilerWarnings.NLS)  ConcurrentMapBasedLongToDoubleFunctionMemoizer(
            final ConcurrentMap<KEY, Double> cache,
            final LongFunction<KEY> keyFunction,
            final LongToDoubleFunction function); @Override double applyAsDouble(final long value); }
ConcurrentMapBasedLongToDoubleFunctionMemoizer extends ConcurrentMapBasedMemoizer<KEY, Double> implements LongToDoubleFunction { @Override public double applyAsDouble(final long value) { final KEY key = keyFunction.apply(value); return computeIfAbsent(key, givenKey -> Double.valueOf(function.applyAsDouble(value))) .doubleValue(); } @SuppressWarnings(CompilerWarnings.NLS)  ConcurrentMapBasedLongToDoubleFunctionMemoizer(
            final ConcurrentMap<KEY, Double> cache,
            final LongFunction<KEY> keyFunction,
            final LongToDoubleFunction function); @Override double applyAsDouble(final long value);  }