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

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

There is a newer version: 5.5.0
Show newest version
package com.jnape.palatable.lambda.functions.builtin.fn2;

import com.jnape.palatable.lambda.adt.product.Product5;
import com.jnape.palatable.lambda.functions.Fn1;
import com.jnape.palatable.lambda.functions.Fn2;
import com.jnape.palatable.lambda.functions.Fn5;

/**
 * Given an {@link Fn5}<A, B, C, D, E, F> and a {@link Product5}<A, B, C, D, E>,
 * 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 fourth argument type
 * @param  the fifth argument type
 * @param  the result type
 */
public final class Into5 implements Fn2, Product5, F> {

    private static final Into5 INSTANCE = new Into5<>();

    @Override
    public F checkedApply(Fn5 fn,
                          Product5 product) {
        return product.into(fn);
    }

    @SuppressWarnings("unchecked")
    public static  Into5 into5() {
        return (Into5) INSTANCE;
    }

    public static  Fn1, F> into5(
            Fn5 fn) {
        return Into5.into5().apply(fn);
    }

    public static  F into5(Fn5 fn,
                                             Product5 product) {
        return Into5.into5(fn).apply(product);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy