@Test public void shouldMemoizeConsumer() { final ConcurrentMap<String, String> cache = new ConcurrentHashMap<>(); final ObjDoubleFunction<String, String> keyFunction = (first, second) -> first + second; final ObjDoubleConsumer<String> consumer = (first, second) -> System.out.println(first + second); final ConcurrentMapBasedObjDoubleConsumerMemoizer<String, String> memoizer = new ConcurrentMapBasedObjDoubleConsumerMemoizer<>( cache, keyFunction, consumer); memoizer.accept("test", 123.456D); }
@Override public void accept(final INPUT input, final double value) { final KEY key = keyFunction.apply(input, value); computeIfAbsent(key, givenKey -> { consumer.accept(input, value); return input; }); }
ConcurrentMapBasedObjDoubleConsumerMemoizer extends ConcurrentMapBasedMemoizer<KEY, INPUT> implements ObjDoubleConsumer<INPUT> { @Override public void accept(final INPUT input, final double value) { final KEY key = keyFunction.apply(input, value); computeIfAbsent(key, givenKey -> { consumer.accept(input, value); return input; }); } }
ConcurrentMapBasedObjDoubleConsumerMemoizer extends ConcurrentMapBasedMemoizer<KEY, INPUT> implements ObjDoubleConsumer<INPUT> { @Override public void accept(final INPUT input, final double value) { final KEY key = keyFunction.apply(input, value); computeIfAbsent(key, givenKey -> { consumer.accept(input, value); return input; }); } @SuppressWarnings(CompilerWarnings.NLS)  ConcurrentMapBasedObjDoubleConsumerMemoizer(
            final ConcurrentMap<KEY, INPUT> cache,
            final ObjDoubleFunction<INPUT, KEY> keyFunction,
            final ObjDoubleConsumer<INPUT> consumer); }
ConcurrentMapBasedObjDoubleConsumerMemoizer extends ConcurrentMapBasedMemoizer<KEY, INPUT> implements ObjDoubleConsumer<INPUT> { @Override public void accept(final INPUT input, final double value) { final KEY key = keyFunction.apply(input, value); computeIfAbsent(key, givenKey -> { consumer.accept(input, value); return input; }); } @SuppressWarnings(CompilerWarnings.NLS)  ConcurrentMapBasedObjDoubleConsumerMemoizer(
            final ConcurrentMap<KEY, INPUT> cache,
            final ObjDoubleFunction<INPUT, KEY> keyFunction,
            final ObjDoubleConsumer<INPUT> consumer); @Override void accept(final INPUT input, final double value); }
ConcurrentMapBasedObjDoubleConsumerMemoizer extends ConcurrentMapBasedMemoizer<KEY, INPUT> implements ObjDoubleConsumer<INPUT> { @Override public void accept(final INPUT input, final double value) { final KEY key = keyFunction.apply(input, value); computeIfAbsent(key, givenKey -> { consumer.accept(input, value); return input; }); } @SuppressWarnings(CompilerWarnings.NLS)  ConcurrentMapBasedObjDoubleConsumerMemoizer(
            final ConcurrentMap<KEY, INPUT> cache,
            final ObjDoubleFunction<INPUT, KEY> keyFunction,
            final ObjDoubleConsumer<INPUT> consumer); @Override void accept(final INPUT input, final double value);  }