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, F}
008 * <SPAN CLASS=TJF>Output:</SPAN> {@code R}.
009 * 
010 * <BR /><BR />
011 * <EMBED CLASS='external-html' DATA-FILE-ID=BIG_FUNCTION>
012 * <EMBED CLASS="globalDefs" DATA-Name='Hex Function' DATA-Number=six>
013 * 
014 * @param <A> The type of the first input-parameter.
015 * @param <B> The type of the second input-parameter.
016 * @param <C> The type of the third input-parameter.
017 * @param <D> The type of the fourth input-parameter.
018 * @param <E> The type of the fifth input-parameter.
019 * @param <F> The type of the last input-parameter.
020 * @param <R> The type of the function-output.
021 */
022@FunctionalInterface
023public interface HexFunction<A, B, C, D, E, F, R>
024{
025    /**
026     * Applies {@code 'this'} function to the given arguments.
027     * <BR /><BR /><EMBED CLASS='external-html' DATA-FILE-ID=FUNC_INTER_METH>
028     *
029     * @param a the first input argument
030     * @param b the second input argument
031     * @param c the third input argument
032     * @param d the fourth input argument
033     * @param e the fifth input argument
034     * @param f the sixth input argument
035     * @return The result of the function.  Result shall be of type {@code 'R'}
036     */
037    public R apply(A a, B b, C c, D d, E e, F f);
038
039    /**
040     * <EMBED CLASS='external-html' DATA-FILE-ID=FUNC_THEN_METHOD>
041     * @param after <EMBED CLASS='external-html' DATA-FILE-ID=FUNC_THEN_AFTER>
042     * 
043     * @return a composed {@code 'HexFunction'}, that first applies {@code 'this'} function, and
044     * then applies the {@code 'after'} function.
045     * 
046     * @throws NullPointerException This is thrown if {@code 'after'} is null.
047     */
048    default <V> HexFunction<A, B, C, D, E, F, V> andThen(Function<? super R, ? extends V> after)
049    {
050        if (after == null)
051            throw new NullPointerException("parameter 'after' has been passed null.");
052
053        return (A a, B b, C c, D d, E e, F f) -> after.apply(this.apply(a, b, c, d, e, f));
054    }
055 
056}