水平有限,欢迎指正
/**
* Represents a function that accepts two arguments and produces a result.
* This is the two-arity specialization of Function.
*
* This is a functional interface whose functional method is apply(Object,Object)
*
* 代表一个接受两个参数,输出一个结果的函数
* 这个是二元的特殊Function
*
* 这个是个函数式接口,函数方法是apply(Object,Object)
*
* @Param<T> the type of the first argument to the function 这个函数第一个参数的类型
* @Param<U> the type of the second argument to the function 这个函数第二个参数的类型
* @Param<R> the type of the result of the function 这个函数结果的类型
*/
public interface BiFunction<T,U,R> {
/**
* Applies this function to the given arguments.
* 将函数引用于给定的参数
*
* @param t the first function argument 第一个函数参数
* @param u the second function argument 第二个函数参数
* @return the function result 函数结果
*/
R apply(T t,U u);
/**
* Return a composed function that first applies this function to its input,and then applies
* the after function to the result.
* If evaluation of either function throws an exception,it is relayed to the caller of the composed
* function.
*
* 返回一个组合函数,这个应用自身函数到入参,然后应用after函数到这个函数的结果。
*
* 如果任意函数求值抛出异常,则这个异常则会转发给这个组合函数的调用者。
* @param after the function to apply after this function is applied 在本地函数应用后应用的函数
* @param <V> the type of output of the after function,and of the composed function
* 这个after函数和组合函数的输出
* @return NullPinterException if after is null 如果after函数为null
*/
default <V> BiFunction<T,U,V> andThen(Function<? super R,?extends V> after) {
Objects.requireNonNull(after);
return (T t, U u) -> after.apply(apply(t, u));
}
}