@Test @SuppressWarnings(CompilerWarnings.UNCHECKED) public void shouldUseCallWrappedConsumer() { final ConcurrentMap<String, String> cache = new ConcurrentHashMap<>(); final ObjIntFunction<String, String> keyFunction = (first, second) -> first + second; final ObjIntConsumer<String> consumer = Mockito.mock(ObjIntConsumer.class); final ConcurrentMapBasedObjIntConsumerMemoizer<String, String> memoizer = new ConcurrentMapBasedObjIntConsumerMemoizer<>( cache, keyFunction, consumer); memoizer.accept("test", 123); Mockito.verify(consumer).accept("test", 123); }
@Override public void accept(final INPUT input, final int value) { final KEY key = keyFunction.apply(input, value); computeIfAbsent(key, givenKey -> { consumer.accept(input, value); return input; }); }
ConcurrentMapBasedObjIntConsumerMemoizer extends ConcurrentMapBasedMemoizer<KEY, INPUT> implements ObjIntConsumer<INPUT> { @Override public void accept(final INPUT input, final int value) { final KEY key = keyFunction.apply(input, value); computeIfAbsent(key, givenKey -> { consumer.accept(input, value); return input; }); } }
ConcurrentMapBasedObjIntConsumerMemoizer extends ConcurrentMapBasedMemoizer<KEY, INPUT> implements ObjIntConsumer<INPUT> { @Override public void accept(final INPUT input, final int value) { final KEY key = keyFunction.apply(input, value); computeIfAbsent(key, givenKey -> { consumer.accept(input, value); return input; }); } @SuppressWarnings(CompilerWarnings.NLS)  ConcurrentMapBasedObjIntConsumerMemoizer(
            final ConcurrentMap<KEY, INPUT> cache,
            final ObjIntFunction<INPUT, KEY> keyFunction,
            final ObjIntConsumer<INPUT> consumer); }
ConcurrentMapBasedObjIntConsumerMemoizer extends ConcurrentMapBasedMemoizer<KEY, INPUT> implements ObjIntConsumer<INPUT> { @Override public void accept(final INPUT input, final int value) { final KEY key = keyFunction.apply(input, value); computeIfAbsent(key, givenKey -> { consumer.accept(input, value); return input; }); } @SuppressWarnings(CompilerWarnings.NLS)  ConcurrentMapBasedObjIntConsumerMemoizer(
            final ConcurrentMap<KEY, INPUT> cache,
            final ObjIntFunction<INPUT, KEY> keyFunction,
            final ObjIntConsumer<INPUT> consumer); @Override void accept(final INPUT input, final int value); }
ConcurrentMapBasedObjIntConsumerMemoizer extends ConcurrentMapBasedMemoizer<KEY, INPUT> implements ObjIntConsumer<INPUT> { @Override public void accept(final INPUT input, final int value) { final KEY key = keyFunction.apply(input, value); computeIfAbsent(key, givenKey -> { consumer.accept(input, value); return input; }); } @SuppressWarnings(CompilerWarnings.NLS)  ConcurrentMapBasedObjIntConsumerMemoizer(
            final ConcurrentMap<KEY, INPUT> cache,
            final ObjIntFunction<INPUT, KEY> keyFunction,
            final ObjIntConsumer<INPUT> consumer); @Override void accept(final INPUT input, final int value);  }