Module bus.core

Interface BiConsumerX<T,U>

Type Parameters:
T - 第一个参数类型
U - 第二个参数类型
All Superinterfaces:
BiConsumer<T,U>, Serializable
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface BiConsumerX<T,U> extends BiConsumer<T,U>, Serializable
可序列化的BiConsumer接口,支持异常抛出和多个消费者组合。
Since:
Java 17+
Author:
Kimi Liu
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    accept(T t, U u)
    对给定的两个参数执行操作,自动处理异常。
    void
    accepting(T t, U u)
    对给定的两个参数执行操作,可能抛出异常。
    default BiConsumerX<T,U>
    andThen(BiConsumerX<? super T,? super U> after)
    返回一个组合的BiConsumerX,先执行当前操作,再执行after操作。
    static <T, U> BiConsumerX<T,U>
    multi(BiConsumerX<T,U>... consumers)
    组合多个BiConsumerX实例,按顺序执行。
    static <T, U> BiConsumerX<T,U>
    返回一个空操作的BiConsumerX,用于占位。

    Methods inherited from interface java.util.function.BiConsumer

    andThen
  • Method Details

    • multi

      @SafeVarargs static <T, U> BiConsumerX<T,U> multi(BiConsumerX<T,U>... consumers)
      组合多个BiConsumerX实例,按顺序执行。
      Type Parameters:
      T - 第一个参数类型
      U - 第二个参数类型
      Parameters:
      consumers - 要组合的BiConsumerX实例
      Returns:
      组合后的BiConsumerX实例
    • nothing

      static <T, U> BiConsumerX<T,U> nothing()
      返回一个空操作的BiConsumerX,用于占位。
      Type Parameters:
      T - 第一个参数类型
      U - 第二个参数类型
      Returns:
      空操作的BiConsumerX实例
    • accepting

      void accepting(T t, U u) throws Throwable
      对给定的两个参数执行操作,可能抛出异常。
      Parameters:
      t - 第一个输入参数
      u - 第二个输入参数
      Throws:
      Throwable - 可能抛出的异常
    • accept

      default void accept(T t, U u)
      对给定的两个参数执行操作,自动处理异常。
      Specified by:
      accept in interface BiConsumer<T,U>
      Parameters:
      t - 第一个输入参数
      u - 第二个输入参数
      Throws:
      RuntimeException - 包装后的运行时异常
    • andThen

      default BiConsumerX<T,U> andThen(BiConsumerX<? super T,? super U> after)
      返回一个组合的BiConsumerX,先执行当前操作,再执行after操作。
      Parameters:
      after - 在当前操作后执行的操作
      Returns:
      组合后的BiConsumerX实例,按顺序执行当前操作和after操作
      Throws:
      NullPointerException - 如果after为null