com.sta.mutils.TetraFunction Maven / Gradle / Ivy
package com.sta.mutils;
import java.util.Objects;
import java.util.function.Function;
/**
* Name: TetraFunction
* Description: Extension of BiFunction.
* @param the type of the first argument to the function
* @param the type of the second argument to the function
* @param the type of the third argument to the function
* @param the type of the 4th argument to the function
* @param the type of the result of the function
*
* Comment: ...
*
* Copyright: Copyright (c) 2020, 2021
* Company: >StA-Soft<
* @author StA
* @version 1.0
*/
@FunctionalInterface
public interface TetraFunction
{
/**
* Applies this function to the given arguments.
*
* @param t0 the first function argument
* @param t1 the second function argument
* @param t2 the third function argument
* @param t3 the 4th function argument
* @return the function result
*/
R apply(T0 t0, T1 t1, T2 t2, T3 t3);
/**
* Returns a composed function that first applies this function to
* its input, and then applies the {@code after} function to the result.
* If evaluation of either function throws an exception, it is relayed to
* the caller of the composed function.
*
* @param the type of output of the {@code after} function, and of the composed function
* @param after the function to apply after this function is applied
* @return a composed function that first applies this function and then applies the {@code after} function
* @throws NullPointerException if after is null
*/
default TetraFunction andThen(Function super R, ? extends V> after)
{
Objects.requireNonNull(after);
return (T0 t0, T1 t1, T2 t2, T3 t3) -> after.apply(apply(t0, t1, t2, t3));
}
}