@Test public void shouldUseCallWrappedConsumer() { final ConcurrentMap<Double, Double> cache = new ConcurrentHashMap<>(); final DoubleConsumer consumer = Mockito.mock(DoubleConsumer.class); final DoubleFunction<Double> keyFunction = Double::valueOf; final ConcurrentMapBasedDoubleConsumerMemoizer<Double> memoizer = new ConcurrentMapBasedDoubleConsumerMemoizer<>( cache, keyFunction, consumer); memoizer.accept(123.456D); Mockito.verify(consumer).accept(123.456D); }
@Override public void accept(final double value) { final KEY key = keyFunction.apply(value); computeIfAbsent(key, givenKey -> { consumer.accept(value); return Double.valueOf(value); }); }
ConcurrentMapBasedDoubleConsumerMemoizer extends ConcurrentMapBasedMemoizer<KEY, Double> implements DoubleConsumer { @Override public void accept(final double value) { final KEY key = keyFunction.apply(value); computeIfAbsent(key, givenKey -> { consumer.accept(value); return Double.valueOf(value); }); } }
ConcurrentMapBasedDoubleConsumerMemoizer extends ConcurrentMapBasedMemoizer<KEY, Double> implements DoubleConsumer { @Override public void accept(final double value) { final KEY key = keyFunction.apply(value); computeIfAbsent(key, givenKey -> { consumer.accept(value); return Double.valueOf(value); }); } @SuppressWarnings(CompilerWarnings.NLS)  ConcurrentMapBasedDoubleConsumerMemoizer(
            final ConcurrentMap<KEY, Double> cache,
            final DoubleFunction<KEY> keyFunction,
            final DoubleConsumer consumer); }
ConcurrentMapBasedDoubleConsumerMemoizer extends ConcurrentMapBasedMemoizer<KEY, Double> implements DoubleConsumer { @Override public void accept(final double value) { final KEY key = keyFunction.apply(value); computeIfAbsent(key, givenKey -> { consumer.accept(value); return Double.valueOf(value); }); } @SuppressWarnings(CompilerWarnings.NLS)  ConcurrentMapBasedDoubleConsumerMemoizer(
            final ConcurrentMap<KEY, Double> cache,
            final DoubleFunction<KEY> keyFunction,
            final DoubleConsumer consumer); @Override void accept(final double value); }
ConcurrentMapBasedDoubleConsumerMemoizer extends ConcurrentMapBasedMemoizer<KEY, Double> implements DoubleConsumer { @Override public void accept(final double value) { final KEY key = keyFunction.apply(value); computeIfAbsent(key, givenKey -> { consumer.accept(value); return Double.valueOf(value); }); } @SuppressWarnings(CompilerWarnings.NLS)  ConcurrentMapBasedDoubleConsumerMemoizer(
            final ConcurrentMap<KEY, Double> cache,
            final DoubleFunction<KEY> keyFunction,
            final DoubleConsumer consumer); @Override void accept(final double value);  }