001package Torello.Java.Function;
002
003import java.util.function.Function;
004
005/**
006 * Function-Pointer
007 * <SPAN CLASS=TJF>Input:</SPAN> {@code A, B, C}
008 * <SPAN CLASS=TJF>Output:</SPAN> {@code R}.
009 * 
010 * <BR /><BR />
011 * <EMBED CLASS="external-html" DATA-FILE-ID=BIGFUNC>
012 * <EMBED CLASS="globalDefs" DATA-Name='Tri Function' DATA-Number=three>
013 * @param <A> The type of the first input-parameter.
014 * @param <B> The type of the second input-parameter.
015 * @param <C> The type of the last input-parameter.
016 * @param <R> The type of the function-output.
017 */
018@FunctionalInterface
019public interface TriFunction<A, B, C, R>
020{
021    /**
022     * Applies {@code 'this'} function to the given arguments.
023     * @param a the first input argument
024     * @param b the second input argument
025     * @param c the third input argument
026     * @return The result of the function.  Return result is of type {@code 'R'}
027     */
028    public R apply(A a, B b, C c);
029
030    /**
031     * <EMBED CLASS="external-html" DATA-FILE-ID="FUNCTHENMETH">
032     * @param after <EMBED CLASS="external-html" DATA-FILE-ID="FUNCTHENAFT">
033     * @return a composed {@code 'TriFunction'}, that first applies {@code 'this'} function, and
034     * then applies the {@code 'after'} function.
035     * @throws NullPointerException This is thrown if {@code 'after'} is null.
036     */
037    default <V> TriFunction<A, B, C, V> andThen(Function<? super R, ? extends V> after)
038    {
039        if (after == null)
040            throw new NullPointerException("parameter 'after' has been passed null.");
041
042        return (A a, B b, C c) -> after.apply(this.apply(a, b, c));
043    }
044 
045}