1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package Torello.Java.Function;

import java.util.function.Function;

/**
 * Function-Pointer
 * <SPAN CLASS=TJF>Input:</SPAN> {@code A, B, C}
 * <SPAN CLASS=TJF>Output:</SPAN> {@code R}.
 * 
 * <BR /><BR />
 * <EMBED CLASS="external-html" DATA-FILE-ID=BIGFUNC>
 * <EMBED CLASS="globalDefs" DATA-Name='Tri Function' DATA-Number=three>
 * @param <A> The type of the first input-parameter.
 * @param <B> The type of the second input-parameter.
 * @param <C> The type of the last input-parameter.
 * @param <R> The type of the function-output.
 */
@FunctionalInterface
public interface TriFunction<A, B, C, R>
{
    /**
     * Applies {@code 'this'} function to the given arguments.
     * @param a the first input argument
     * @param b the second input argument
     * @param c the third input argument
     * @return The result of the function.  Return result is of type {@code 'R'}
     */
    public R apply(A a, B b, C c);

    /**
     * <EMBED CLASS="external-html" DATA-FILE-ID="FUNCTHENMETH">
     * @param after <EMBED CLASS="external-html" DATA-FILE-ID="FUNCTHENAFT">
     * @return a composed {@code 'TriFunction'}, that first applies {@code 'this'} function, and
     * then applies the {@code 'after'} function.
     * @throws NullPointerException This is thrown if {@code 'after'} is null.
     */
    default <V> TriFunction<A, B, C, V> andThen(Function<? super R, ? extends V> after)
    {
        if (after == null)
            throw new NullPointerException("parameter 'after' has been passed null.");

        return (A a, B b, C c) -> after.apply(this.apply(a, b, c));
    }
 
}