001package Torello.Java.Function; 002 003import java.util.function.Function; 004 005/** 006 * Function-Pointer 007 * <SPAN CLASS=TJF>Input:</SPAN> {@code int, int, int} 008 * <SPAN CLASS=TJF>Output:</SPAN> {@code R}. 009 * 010 * <BR /><BR />Primitive's Extension to Java's {@code java.util.function.*} package. 011 * 012 * <BR /><BR />This {@code FunctionalInterface} has an {@code apply(...)} method which accepts 013 * three primitives: three {@code int}-primitives. 014 */ 015@FunctionalInterface 016public interface TriIntFunc<R> 017{ 018 /** 019 * Applies a user-provided function to input aruments, returning a result of type {@code R} 020 * <BR /><BR /><EMBED CLASS='external-html' DATA-FILE-ID=FUNC_INTER_METH> 021 * 022 * @param i1 The first integer-parameter. 023 * @param i2 The second integer-parameter. 024 * @param i3 The third integer-parameter. 025 * @return The result of the function. Return result is of type {@code 'R'} 026 */ 027 public R apply(int i1, int i2, int i3); 028 029 /** 030 * Returns a composed function that first applies {@code 'this'} function to its input, and 031 * then applies the {@code 'after'} function to the result. If evaluation of either function 032 * throws an exception, it is relayed to the caller of the composed function. 033 * 034 * @param <V> The output-type of the {@code 'after'} function, and also of the (returned) 035 * {@code 'composed'} function. 036 * 037 * @param after The function to apply, after this function is applied. 038 * @throws NullPointerException This throws if null is passed to {@code 'after'}. 039 */ 040 public default <V> TriIntFunc<V> andThen(Function<R, V> after) 041 { 042 if (after == null) throw new NullPointerException 043 ("null has been passed to parameter 'after'"); 044 045 return (int i1, int i2, int i3) -> after.apply(this.apply(i1, i2, i3)); 046 } 047}