@Test public void shouldUseCallWrappedConsumer() { final ConcurrentMap<Integer, Integer> cache = new ConcurrentHashMap<>(); final IntConsumer consumer = Mockito.mock(IntConsumer.class); final IntFunction<Integer> keyFunction = Integer::valueOf; final ConcurrentMapBasedIntConsumerMemoizer<Integer> memoizer = new ConcurrentMapBasedIntConsumerMemoizer<>( cache, keyFunction, consumer); memoizer.accept(123); Mockito.verify(consumer).accept(123); }
@Override public void accept(final int value) { final KEY key = keyFunction.apply(value); computeIfAbsent(key, givenKey -> { consumer.accept(value); return Integer.valueOf(value); }); }
ConcurrentMapBasedIntConsumerMemoizer extends ConcurrentMapBasedMemoizer<KEY, Integer> implements IntConsumer { @Override public void accept(final int value) { final KEY key = keyFunction.apply(value); computeIfAbsent(key, givenKey -> { consumer.accept(value); return Integer.valueOf(value); }); } }
ConcurrentMapBasedIntConsumerMemoizer extends ConcurrentMapBasedMemoizer<KEY, Integer> implements IntConsumer { @Override public void accept(final int value) { final KEY key = keyFunction.apply(value); computeIfAbsent(key, givenKey -> { consumer.accept(value); return Integer.valueOf(value); }); } @SuppressWarnings(CompilerWarnings.NLS)  ConcurrentMapBasedIntConsumerMemoizer(
            final ConcurrentMap<KEY, Integer> cache,
            final IntFunction<KEY> keyFunction,
            final IntConsumer consumer); }
ConcurrentMapBasedIntConsumerMemoizer extends ConcurrentMapBasedMemoizer<KEY, Integer> implements IntConsumer { @Override public void accept(final int value) { final KEY key = keyFunction.apply(value); computeIfAbsent(key, givenKey -> { consumer.accept(value); return Integer.valueOf(value); }); } @SuppressWarnings(CompilerWarnings.NLS)  ConcurrentMapBasedIntConsumerMemoizer(
            final ConcurrentMap<KEY, Integer> cache,
            final IntFunction<KEY> keyFunction,
            final IntConsumer consumer); @Override void accept(final int value); }
ConcurrentMapBasedIntConsumerMemoizer extends ConcurrentMapBasedMemoizer<KEY, Integer> implements IntConsumer { @Override public void accept(final int value) { final KEY key = keyFunction.apply(value); computeIfAbsent(key, givenKey -> { consumer.accept(value); return Integer.valueOf(value); }); } @SuppressWarnings(CompilerWarnings.NLS)  ConcurrentMapBasedIntConsumerMemoizer(
            final ConcurrentMap<KEY, Integer> cache,
            final IntFunction<KEY> keyFunction,
            final IntConsumer consumer); @Override void accept(final int value);  }