Class GenericBuilder<T>

java.lang.Object
org.aoju.bus.core.builder.GenericBuilder<T>
All Implemented Interfaces:
Serializable, Builder<T>

public class GenericBuilder<T> extends Object implements Builder<T>
通用Builder
Since:
Java 17+
Author:
Kimi Liu
See Also:
  • Constructor Details

    • GenericBuilder

      public GenericBuilder(Supplier<T> instant)
      构造
      Parameters:
      instant - 实例化器
  • Method Details

    • of

      public static <T> GenericBuilder<T> of(Supplier<T> instant)
      通过无参数实例化器创建GenericBuilder
      Type Parameters:
      T - 目标类型
      Parameters:
      instant - 实例化器
      Returns:
      GenericBuilder对象
    • of

      public static <T, P1> GenericBuilder<T> of(Supplier1<T,P1> instant, P1 p1)
      通过1参数实例化器创建GenericBuilder
      Type Parameters:
      T - 目标类型
      P1 - 参数一类型
      Parameters:
      instant - 实例化器
      p1 - 参数一
      Returns:
      GenericBuilder对象
    • of

      public static <T, P1, P2> GenericBuilder<T> of(Supplier2<T,P1,P2> instant, P1 p1, P2 p2)
      通过2参数实例化器创建GenericBuilder
      Type Parameters:
      T - 目标类型
      P1 - 参数一类型
      P2 - 参数二类型
      Parameters:
      instant - 实例化器
      p1 - 参数一
      p2 - 参数二
      Returns:
      GenericBuilder对象
    • of

      public static <T, P1, P2, P3> GenericBuilder<T> of(Supplier3<T,P1,P2,P3> instant, P1 p1, P2 p2, P3 p3)
      通过3参数实例化器创建GenericBuilder
      Type Parameters:
      T - 目标类型
      P1 - 参数一类型
      P2 - 参数二类型
      P3 - 参数三类型
      Parameters:
      instant - 实例化器
      p1 - 参数一
      p2 - 参数二
      p3 - 参数三
      Returns:
      GenericBuilder对象
    • of

      public static <T, P1, P2, P3, P4> GenericBuilder<T> of(Supplier4<T,P1,P2,P3,P4> instant, P1 p1, P2 p2, P3 p3, P4 p4)
      通过4参数实例化器创建GenericBuilder
      Type Parameters:
      T - 目标类型
      P1 - 参数一类型
      P2 - 参数二类型
      P3 - 参数三类型
      P4 - 参数四类型
      Parameters:
      instant - 实例化器
      p1 - 参数一
      p2 - 参数二
      p3 - 参数三
      p4 - 参数四
      Returns:
      GenericBuilder对象
    • of

      public static <T, P1, P2, P3, P4, P5> GenericBuilder<T> of(Supplier5<T,P1,P2,P3,P4,P5> instant, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
      通过5参数实例化器创建GenericBuilder
      Type Parameters:
      T - 目标类型
      P1 - 参数一类型
      P2 - 参数二类型
      P3 - 参数三类型
      P4 - 参数四类型
      P5 - 参数五类型
      Parameters:
      instant - 实例化器
      p1 - 参数一
      p2 - 参数二
      p3 - 参数三
      p4 - 参数四
      p5 - 参数五
      Returns:
      GenericBuilder对象
    • with

      public GenericBuilder<T> with(Consumer<T> consumer)
      调用无参数方法
      Parameters:
      consumer - 无参数Consumer
      Returns:
      GenericBuilder对象
    • with

      public <P1> GenericBuilder<T> with(BiConsumer<T,P1> consumer, P1 p1)
      调用1参数方法
      Type Parameters:
      P1 - 参数一类型
      Parameters:
      consumer - 1参数Consumer
      p1 - 参数一
      Returns:
      GenericBuilder对象
    • with

      public <P1, P2> GenericBuilder<T> with(Consumer3<T,P1,P2> consumer, P1 p1, P2 p2)
      调用2参数方法
      Type Parameters:
      P1 - 参数一类型
      P2 - 参数二类型
      Parameters:
      consumer - 2参数Consumer
      p1 - 参数一
      p2 - 参数二
      Returns:
      GenericBuilder对象
    • build

      public T build()
      构建
      Specified by:
      build in interface Builder<T>
      Returns:
      目标对象