BiConsumer翻译

水平有限,翻译有错误请指正

/**
 * 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);
        };
    }

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值