001package Torello.Java.Function; 002 003import java.util.function.Function; 004 005/** 006 * Function-Pointer 007 * <SPAN CLASS=TJF>Input:</SPAN> {@code int, long} 008 * <SPAN CLASS=TJF>Output:</SPAN> {@code R}. 009 * 010 * <BR /><BR /> 011 * <EMBED CLASS='external-html' DATA-FILE-ID=TWO_PRIMITIVE_FUNC> 012 * <EMBED CLASS="globalDefs" DATA-Type1=int DATA-Type2=long> 013 * 014 * @param <R> The type of the function-output. 015 */ 016@FunctionalInterface 017public interface IntLongFunction<R> 018{ 019 /** 020 * Applies this function to the given arguments. 021 * <BR /><BR /><EMBED CLASS='external-html' DATA-FILE-ID=FUNC_INTER_METH> 022 * 023 * @param i The integer (first) argument to the function. 024 * @param l The long (second) argument to the function. 025 * @return The function result. Result shall be of type {@code 'R'} 026 */ 027 public R apply(int i, long l); 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> IntLongFunction<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 i, long l) -> after.apply(this.apply(i, l)); 046 } 047}