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, D, E}
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='Quint Function' DATA-Number=five>
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 third input-parameter.
016 * @param <D> The type of the fourth input-parameter.
017 * @param <E> The type of the last input-parameter.
018 * @param <R> The type of the function-output.
019 */
020public interface QuintFunction<A, B, C, D, E, R>
021{
022    /**
023     * Applies {@code 'this'} function to the given arguments.
024     * @param a the first input argument
025     * @param b the second input argument
026     * @param c the third input argument
027     * @param d the fourth input argument
028     * @param e the fifth input argument
029     * @return The result of the function.  Return result is of type {@code 'R'}
030     */
031    public R apply(A a, B b, C c, D d, E e);
032
033    /**
034     * <EMBED CLASS="external-html" DATA-FILE-ID="FUNCTHENMETH">
035     * @param after <EMBED CLASS="external-html" DATA-FILE-ID="FUNCTHENAFT">
036     * @return a composed {@code 'QuintFunction'}, that first applies {@code 'this'} function, and
037     * then applies the {@code 'after'} function.
038     * @throws NullPointerException This is thrown if {@code 'after'} is null.
039     */
040    default <V> QuintFunction<A, B, C, D, E, V> andThen(Function<? super R, ? extends V> after)
041    {
042        if (after == null)
043            throw new NullPointerException("parameter 'after' has been passed null.");
044
045        return (A a, B b, C c, D d, E e) -> after.apply(this.apply(a, b, c, d, e));
046    }
047 
048}