wtf.metio.memoization.jool.Consumer9Memoizer Maven / Gradle / Ivy
/*
* SPDX-FileCopyrightText: The memoization.java Authors
* SPDX-License-Identifier: 0BSD
*/
package wtf.metio.memoization.jool;
import org.jooq.lambda.function.Consumer9;
import org.jooq.lambda.function.Function9;
import wtf.metio.memoization.core.AbstractMemoizer;
import java.util.concurrent.ConcurrentMap;
import static java.util.Objects.requireNonNull;
final class Consumer9Memoizer
extends AbstractMemoizer
implements Consumer9 {
private final Function9 keyFunction;
private final Consumer9 consumer;
Consumer9Memoizer(
final ConcurrentMap cache,
final Function9 keyFunction,
final Consumer9 consumer) {
super(cache);
this.keyFunction = requireNonNull(keyFunction, "Provide a key function.");
this.consumer = requireNonNull(consumer,
"Cannot memoize a NULL Consumer9 - provide an actual Consumer9 to fix this.");
}
@Override
public void accept(final TYPE1 v1, final TYPE2 v2, final TYPE3 v3, final TYPE4 v4, final TYPE5 v5, final TYPE6 v6, final TYPE7 v7, final TYPE8 v8, final TYPE9 v9) {
computeIfAbsent(keyFunction.apply(v1, v2, v3, v4, v5, v6, v7, v8, v9), key -> {
consumer.accept(v1, v2, v3, v4, v5, v6, v7, v8, v9);
return key;
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy