Interface SerializableConsumer<T>

Type Parameters:
T - the input type | 输入类型
All Superinterfaces:
Consumer<T>, 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 SerializableConsumer<T> extends Consumer<T>, Serializable
Serializable Consumer Interface 可序列化Consumer接口

A Consumer that is also Serializable, enabling lambda metadata extraction.

一个同时也是Serializable的Consumer,可以提取lambda元数据。

Features | 主要功能:

  • Serializable Consumer for lambda metadata extraction - 可序列化Consumer用于lambda元数据提取
  • Chainable with andThen - 可通过andThen链接
  • No-op factory method - 空操作工厂方法

Usage Examples | 使用示例:

SerializableConsumer<String> printer = System.out::println;
printer.accept("Hello");

Security | 安全性:

  • Thread-safe: Depends on implementation - 线程安全: 取决于实现
  • Null-safe: Depends on implementation - 空值安全: 取决于实现
Since:
JDK 25, opencode-base-reflect V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Details

    • of

      static <T> SerializableConsumer<T> of(SerializableConsumer<T> consumer)
      Creates a SerializableConsumer 创建SerializableConsumer
      Type Parameters:
      T - the input type | 输入类型
      Parameters:
      consumer - the consumer | 消费者
      Returns:
      the serializable consumer | 可序列化消费者
    • noOp

      static <T> SerializableConsumer<T> noOp()
      Creates a no-op consumer 创建空操作消费者
      Type Parameters:
      T - the input type | 输入类型
      Returns:
      the no-op consumer | 空操作消费者
    • andThen

      default SerializableConsumer<T> andThen(SerializableConsumer<? super T> after)
      Chains this consumer with another 将此消费者与另一个链接
      Parameters:
      after - the consumer to run after | 之后运行的消费者
      Returns:
      the chained consumer | 链接后的消费者