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 /> 011 * Primitive's Extension to Java's {@code java.util.function.*} package. 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 * @param i1 The first integer-parameter. 021 * @param i2 The second integer-parameter. 022 * @param i3 The third integer-parameter. 023 * @return The result of the function. Return result is of type {@code 'R'} 024 */ 025 public R apply(int i1, int i2, int i3); 026 027 /** 028 * Returns a composed function that first applies {@code 'this'} function to its input, and 029 * then applies the {@code 'after'} function to the result. If evaluation of either function 030 * throws an exception, it is relayed to the caller of the composed function. 031 * 032 * @param <V> The output-type of the {@code 'after'} function, and also of the (returned) 033 * {@code 'composed'} function. 034 * 035 * @param after The function to apply, after this function is applied. 036 * @throws NullPointerException This throws if null is passed to {@code 'after'}. 037 */ 038 public default <V> TriIntFunc<V> andThen(Function<R, V> after) 039 { 040 if (after == null) throw new NullPointerException 041 ("null has been passed to parameter 'after'"); 042 043 return (int i1, int i2, int i3) -> after.apply(this.apply(i1, i2, i3)); 044 } 045}