水平有限,翻译有错误请指正
/**
* Represents an operation tht accepts two input arguments and returns no result.
* This is the two-arity specialization of Consumer.
* Unlike most other functional interfaces,
* BiConsumer is expected to operate via side-effects.
*
* This is a functional interface whose functional method is accept(Object,Object)
*
* 代表一个接受两个入参,不返回任何结果的操作
* 这是二元的特殊化Consumer
* 不像其他函数式的接口,BiConsumer可以通过副作用来发挥作用
*
* 这是一个函数式接口,函数接口是accept(Object,Object);
*
* @Param<T> the type of the first argument to the operation 操作的第一个参数的类型
* @Param<U> the type of the second argument of the operation 操作的第二个参数的类型
*/
public interface BiConsumer<T,U> {
/**
* Performs this operation on the given arguments
*
* 执行给定参数的操作
* @param t the first input argument 第一个入参
* @param u the second input argument 第二个参数
*/
void accept(T t,U u);
/**
* Returns a composed BiConsumer that performs,in sequence,this operation followed by the after operation.
* If performing either operation throws an exception,it is relayed to the caller of the composed operation.
* If performing this operation throws an exception,the after operation will not be performed.
*
* 返回一个组合执行的BiConsumer,依次,先这个接口的操作,然后在after的操作
* 如果执行任意一个操作抛出了异常,这个异常将会传递给这个组合方法的调用者。
* 如果这个接口的操作抛出了异常,则after的操作不会执行
*
* @param after the operation to perform after this operation 在这个接口操作后面执行的操作
* @return a composed BiConsumer that performs in sequence this operation followed by the after operation.
* 先执行这个接口方法再执行after方法的组合BiConsumer
* @throws NullPointerException if after is null 如果after是null
*/
default BiConsumer<T,U> andThen(BiConsumer<? super T,? super U> after){
Objects.requireNonNull(after);
return (l,r)->{
accept(l,r);
after.accept(l,r);
};
}
}