com.sta.mutils.TriFunction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xtools Show documentation
Show all versions of xtools Show documentation
Executable tools for all projects.
package com.sta.mutils;
import java.util.Objects;
import java.util.function.Function;
/**
* Name: TriFunction
* 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 result of the function
*
* Comment: ...
*
* Copyright: Copyright (c) 2020
* Company: >StA-Soft<
* @author StA
* @version 1.0
*/
@FunctionalInterface
public interface TriFunction
{
/**
* 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
* @return the function result
*/
R apply(T0 t0, T1 t1, T2 t2);
/**
* 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 TriFunction andThen(Function super R, ? extends V> after)
{
Objects.requireNonNull(after);
return (T0 t0, T1 t1, T2 t2) -> after.apply(apply(t0, t1, t2));
}
}