Class ContextBeanCreator<T>

java.lang.Object
org.apache.juneau.cp.ContextBeanCreator<T>
Type Parameters:
T - The bean type.
Direct Known Subclasses:
HttpPartParser.Creator, HttpPartSerializer.Creator

public class ContextBeanCreator<T> extends Object
Utility class for instantiating a Context bean.

Contains either a pre-existing Context bean, or a builder for that bean. If it's a builder, then annotations can be applied to it.

See Also:
  • Constructor Details

  • Method Details

    • create

      public static <T> ContextBeanCreator<T> create(Class<T> type)
      Creator.
      Type Parameters:
      T - The bean type.
      Parameters:
      type - The bean type.
      Returns:
      A new creator object.
    • impl

      public ContextBeanCreator<T> impl(Object value)
      Sets an already instantiated object on this creator.
      Parameters:
      value - The bean to set.
      Returns:
      This object.
    • type

      public ContextBeanCreator<T> type(Class<? extends T> value)
      Sets the implementation type of the bean.

      The class type must extend from Context and have a builder create method.

      Parameters:
      value - The bean type.
      Returns:
      This object.
    • builder

      public <B extends Context.Builder> Optional<B> builder(Class<B> c)
      Returns access to the inner builder if the builder exists and is of the specified type.
      Type Parameters:
      B - The builder class type.
      Parameters:
      c - The builder class type.
      Returns:
      An optional containing the builder if it exists.
    • builder

      public <B extends Context.Builder> ContextBeanCreator<T> builder(Class<B> c, Consumer<B> operation)
      Applies an operation to the builder in this creator object.

      Typically used to allow you to execute operations without breaking the fluent flow of the client builder. The operation is ignored if the builder isn't the specified type.

      Type Parameters:
      B - The builder class type.
      Parameters:
      c - The builder class type.
      operation - The operation to apply.
      Returns:
      This object.
    • canApply

      public boolean canApply(AnnotationWorkList work)
      Returns true if any of the annotations/appliers can be applied to the inner builder (if it has one).
      Parameters:
      work - The work to check.
      Returns:
      This object.
    • apply

      Applies the specified annotations to all applicable serializer builders in this group.
      Parameters:
      work - The annotations to apply.
      Returns:
      This object.
    • copy

      Creates a new copy of this creator.
      Returns:
      A new copy of this creator.
    • create

      public T create()
      Returns the built bean.
      Returns:
      The built bean.