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