Class Assembly<I,T,O>

java.lang.Object
net.orbyfied.coldlib.util.Assembly<I,T,O>
Type Parameters:
I - The intermediate type.
T - The result type (finalized).
O - The options type.

public class Assembly<I,T,O> extends Object
Pipeline for creating and initializing an instance of type R with options of type O.
  • Field Details

    • defaultOptionProvider

      protected final Supplier<O> defaultOptionProvider
      The function which provides the default options object. This can be null or return null, in that case null will be used as the default options.
    • instanceFactory

      protected final Assembly.InstanceFactory<I,O> instanceFactory
      The instance factory responsible for creating the first instance.
    • intermediateLine

      protected final Assembly.Line<I,O> intermediateLine
      The pipeline to transform the intermediate instance.
    • finalizer

      protected final Function<I,T> finalizer
      The finalizer function.
    • resultLine

      protected final Assembly.Line<T,O> resultLine
      The pipeline to transform the result instance.
  • Method Details

    • getDefaultOptions

      protected O getDefaultOptions()
      Get the default options if defined.
      Returns:
      The default options or null (also valid).
    • build

      public T build()
      Assembles (creates, initializes, prepares) a new instance of type T with the default options.
      Returns:
      The built instance.
      See Also:
    • build

      public T build(O options)
      Assembles (creates, initializes, prepares) a new instance of type T with the provided options (nullable).
      Parameters:
      options - The options to assemble with. Can be null.
      Returns:
      The built instance.
    • toBuilder

      public Assembly.Builder<I,T,O> toBuilder()
      Creates a new builder with the properties of this instance set.
      Returns:
      The builder instance.
    • getIntermediateType

      public Class<I> getIntermediateType()
    • getResultType

      public Class<T> getResultType()
    • getOptionsType

      public Class<O> getOptionsType()
    • builder

      public static <I, T, O> Assembly.Builder<I,T,O> builder(Class<I> iClass, Class<T> tClass, Class<O> oClass)
      Create a new builder instance.
      Type Parameters:
      I - The intermediate type.
      T - The result type.
      O - The options type.
      Parameters:
      iClass - The intermediate type.
      tClass - The result type.
      oClass - The options type.
      Returns:
      The builder instance.