All Downloads are FREE. Search and download functionalities are using the official Maven repository.

wtf.metio.memoization.jool.Function15Memoizer Maven / Gradle / Ivy

The newest version!
/*
 * SPDX-FileCopyrightText: The memoization.java Authors
 * SPDX-License-Identifier: 0BSD
 */

package wtf.metio.memoization.jool;

import org.jooq.lambda.function.Function15;
import wtf.metio.memoization.core.AbstractMemoizer;

import java.util.concurrent.ConcurrentMap;

import static java.util.Objects.requireNonNull;

final class Function15Memoizer
        extends AbstractMemoizer
        implements Function15 {

    private final Function15 keyFunction;
    private final Function15 function;

    Function15Memoizer(
            final ConcurrentMap cache,
            final Function15 keyFunction,
            final Function15 function) {
        super(cache);
        this.keyFunction = requireNonNull(keyFunction, "Provide a key function.");
        this.function = requireNonNull(function,
                "Cannot memoize a NULL Function15 - provide an actual Function15 to fix this.");
    }

    @Override
    public OUTPUT apply(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, final TYPE10 v10, final TYPE11 v11, final TYPE12 v12, final TYPE13 v13, final TYPE14 v14, final TYPE15 v15) {
        return computeIfAbsent(keyFunction.apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15),
                key -> function.apply(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15));
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy