Package org.apache.juneau.cp
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
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 Summary
ModifierConstructorDescriptionprotected
ContextBeanCreator
(Class<T> type) Constructor.protected
ContextBeanCreator
(ContextBeanCreator<T> copyFrom) Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionapply
(AnnotationWorkList work) Applies the specified annotations to all applicable serializer builders in this group.<B extends Context.Builder>
Optional<B>Returns access to the inner builder if the builder exists and is of the specified type.<B extends Context.Builder>
ContextBeanCreator<T>Applies an operation to the builder in this creator object.boolean
canApply
(AnnotationWorkList work) Returns true if any of the annotations/appliers can be applied to the inner builder (if it has one).copy()
Creates a new copy of this creator.create()
Returns the built bean.static <T> ContextBeanCreator<T>
Creator.Sets an already instantiated object on this creator.Sets the implementation type of the bean.
-
Constructor Details
-
ContextBeanCreator
Constructor.- Parameters:
type
- The bean type.
-
ContextBeanCreator
Copy constructor.- Parameters:
copyFrom
- The creator to copy from.
-
-
Method Details
-
create
Creator.- Type Parameters:
T
- The bean type.- Parameters:
type
- The bean type.- Returns:
- A new creator object.
-
impl
Sets an already instantiated object on this creator.- Parameters:
value
- The bean to set.- Returns:
- This object.
-
type
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
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
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
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
Returns the built bean.- Returns:
- The built bean.
-