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