Class SimplePooledObjectFactory.Builder<T>

java.lang.Object
cloud.opencode.base.pool.factory.SimplePooledObjectFactory.Builder<T>
Type Parameters:
T - the type of object being pooled - 池化对象类型
Enclosing class:
SimplePooledObjectFactory<T>

public static final class SimplePooledObjectFactory.Builder<T> extends Object
Builder for SimplePooledObjectFactory. SimplePooledObjectFactory 的建造者。

Provides a fluent API for configuring all lifecycle callbacks.

提供用于配置所有生命周期回调的流式 API。

Since:
JDK 25, opencode-base-pool V1.0.3
Author:
Leon Soo www.LeonSoo.com
  • Method Details

    • destroyer

      public SimplePooledObjectFactory.Builder<T> destroyer(Consumer<T> destroyer)
      Sets the destroyer callback. 设置销毁器回调。
      Parameters:
      destroyer - the destroyer (must not be null) - 销毁器(不能为空)
      Returns:
      this builder - 此建造者
      Throws:
      NullPointerException - if destroyer is null - 如果销毁器为空
    • validator

      public SimplePooledObjectFactory.Builder<T> validator(Predicate<T> validator)
      Sets the validator callback. 设置验证器回调。
      Parameters:
      validator - the validator (must not be null) - 验证器(不能为空)
      Returns:
      this builder - 此建造者
      Throws:
      NullPointerException - if validator is null - 如果验证器为空
    • activator

      public SimplePooledObjectFactory.Builder<T> activator(Consumer<T> activator)
      Sets the activator callback. 设置激活器回调。
      Parameters:
      activator - the activator (must not be null) - 激活器(不能为空)
      Returns:
      this builder - 此建造者
      Throws:
      NullPointerException - if activator is null - 如果激活器为空
    • passivator

      public SimplePooledObjectFactory.Builder<T> passivator(Consumer<T> passivator)
      Sets the passivator callback. 设置钝化器回调。
      Parameters:
      passivator - the passivator (must not be null) - 钝化器(不能为空)
      Returns:
      this builder - 此建造者
      Throws:
      NullPointerException - if passivator is null - 如果钝化器为空
    • build

      public SimplePooledObjectFactory<T> build()
      Builds the factory. 构建工厂。
      Returns:
      the configured factory - 配置好的工厂