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