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

com.jnape.palatable.lambda.functions.builtin.fn2.Into3 Maven / Gradle / Ivy

package com.jnape.palatable.lambda.functions.builtin.fn2;

import com.jnape.palatable.lambda.adt.product.Product3;
import com.jnape.palatable.lambda.functions.Fn1;
import com.jnape.palatable.lambda.functions.Fn2;
import com.jnape.palatable.lambda.functions.Fn3;

/**
 * Given an {@link Fn3}<A, B, C, D> and a {@link Product3}<A, B, C>, destructure
 * the product and apply the slots as arguments to the function, returning the result.
 *
 * @param  the first argument type
 * @param  the second argument type
 * @param  the third argument type
 * @param  the result type
 */
public final class Into3 implements Fn2, Product3, D> {

    private static final Into3 INSTANCE = new Into3();

    @Override
    public D apply(Fn3 fn, Product3 product) {
        return product.into(fn);
    }

    @SuppressWarnings("unchecked")
    public static  Into3 into3() {
        return INSTANCE;
    }

    public static  Fn1, D> into3(Fn3 fn) {
        return Into3.into3().apply(fn);
    }

    public static  D into3(Fn3 fn,
                                       Product3 product) {
        return Into3.into3(fn).apply(product);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy