Class SerializerSet.Builder
- All Implemented Interfaces:
BeanStoreOverridable<SerializerSet.Builder>
- Enclosing class:
- SerializerSet
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreate an empty serializer group builder.protectedBuilder(SerializerSet copyFrom) Clone an existing serializer group.protectedBuilder(SerializerSet.Builder copyFrom) Clone an existing serializer group builder. -
Method Summary
Modifier and TypeMethodDescriptionAdds the specified serializers to this group.add(Serializer... s) Registers the specified serializers with this group.apply(AnnotationWorkList work) Applies the specified annotations to all applicable serializer builders in this group.Returns the bean store used by this builder.build()Builds the serializer set.booleancanApply(AnnotationWorkList work) Returnstrue if at least one of the specified annotations can be applied to at least one serializer builder in this group.clear()Clears out any existing serializers in this group.copy()Makes a copy of this builder.<T extends Serializer.Builder<?>>
SerializerSet.BuilderPerforms an action on all serializer builders of the specified type in this group.forEach(Consumer<Serializer.Builder<?>> action) Performs an action on all serializer builders in this group.forEachOSS(Consumer<OutputStreamSerializer.Builder<?>> action) Performs an action on all output stream serializer builders in this group.forEachWS(Consumer<WriterSerializer.Builder<?>> action) Performs an action on all writer serializer builders in this group.Overrides the bean returned by thebuild()method with a pre-built instance.inner()Returns direct access to theSerializerandSerializer.Builderobjects in this builder.final SerializerSet.BuildermarshallingContext(Consumer<MarshallingContext.Builder> operation) Applies an operation to the bean context builder.Associates an existing bean context builder with all serializer builders in this group.overridingBeanStore(BeanStore store) Installs the suppliedBeanStoreas theoverridingParentof this builder's bean store.Sets the specified serializers for this group.toString()
-
Constructor Details
-
Builder
Create an empty serializer group builder.- Parameters:
beanStore- The bean store to use for creating beans.
-
Builder
Clone an existing serializer group builder.Serializer builders will be cloned during this process.
- Parameters:
copyFrom- The serializer group that we're copying settings and serializers from.
Cannot benull .
-
Builder
Clone an existing serializer group.- Parameters:
copyFrom- The serializer group that we're copying settings and serializers from.
Cannot benull .
-
-
Method Details
-
beanStore
Returns the bean store used by this builder.- Returns:
- The bean store used by this builder.
-
overridingBeanStore
Installs the suppliedBeanStoreas theoverridingParentof this builder's bean store.Wraps the current
beanStore()in a freshBasicBeanStorewhoseoverridingParentis the supplied store, so test-time overrides win over the builder's regular bean lookups during construction-time reflective injection. Passingnullis a no-op.- Specified by:
overridingBeanStorein interfaceBeanStoreOverridable<SerializerSet.Builder>- Parameters:
store- The override layer. Can benull (no-op).- Returns:
- This object.
- Since:
- 10.0.0
-
add
Adds the specified serializers to this group.Entries are added in-order to the beginning of the list in the group.
The
SerializerSet.NoInheritclass can be used to clear out the existing list of serializers before adding the new entries.Example:
SerializerSet.Builder
builder = SerializerSet.create ();// Create an empty builder. builder .add(FooSerializer.class );// Now contains: [FooSerializer] builder .add(BarSerializer.class , BazSerializer.class );// Now contains: [BarParser,BazSerializer,FooSerializer] builder .add(NoInherit.class , QuxSerializer.class );// Now contains: [QuxSerializer] - Parameters:
values- The serializers to add to this group.- Returns:
- This object.
- Throws:
IllegalArgumentException- If one or more values do not extend fromSerializer.
-
add
Registers the specified serializers with this group.When passing in pre-instantiated serializers to this group, applying properties and transforms to the group do not affect them.
- Parameters:
s- The serializers to append to this group.- 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.
-
marshallingContext
Associates an existing bean context builder with all serializer builders in this group.- Parameters:
value- The bean context builder to associate.
Can benull (clears any previously-associated bean context builder).- Returns:
- This object.
-
marshallingContext
public final SerializerSet.Builder marshallingContext(Consumer<MarshallingContext.Builder> operation) Applies an operation to the bean context builder.- Parameters:
operation- The operation to apply.- Returns:
- This object.
-
canApply
Returnstrue if at least one of the specified annotations can be applied to at least one serializer builder in this group.- Parameters:
work- The work to check.- Returns:
true if at least one of the specified annotations can be applied to at least one serializer builder in this group.
-
clear
Clears out any existing serializers in this group.- Returns:
- This object.
-
copy
Makes a copy of this builder.- Returns:
- A new copy of this builder.
-
forEach
public <T extends Serializer.Builder<?>> SerializerSet.Builder forEach(Class<T> type, Consumer<T> action) Performs an action on all serializer builders of the specified type in this group.- Type Parameters:
T- The serializer builder type.- Parameters:
type- The serializer builder type.action- The action to perform.- Returns:
- This object.
-
forEach
Performs an action on all serializer builders in this group.- Parameters:
action- The action to perform.- Returns:
- This object.
-
forEachOSS
Performs an action on all output stream serializer builders in this group.- Parameters:
action- The action to perform.- Returns:
- This object.
-
forEachWS
Performs an action on all writer serializer builders in this group.- Parameters:
action- The action to perform.- Returns:
- This object.
-
impl
Overrides the bean returned by thebuild()method with a pre-built instance.- Parameters:
value- The pre-built instance.
Can benull (clears the override;build()constructs a new instance).- Returns:
- This object.
-
inner
Returns direct access to theSerializerandSerializer.Builderobjects in this builder.Provided to allow for any extraneous modifications to the list not accomplishable via other methods on this builder such as re-ordering/adding/removing entries.
Note that it is up to the user to ensure that the list only contains
SerializerandSerializer.Builderobjects.- Returns:
- The inner list of entries in this builder.
-
set
Sets the specified serializers for this group.Existing values are overwritten.
The
SerializerSet.Inheritclass can be used to insert existing entries in this group into the position specified.Example:
SerializerSet.Builder
builder = SerializerSet.create ();// Create an empty builder. builder .set(FooSerializer.class );// Now contains: [FooSerializer] builder .set(BarSerializer.class , BazSerializer.class );// Now contains: [BarParser,BazSerializer] builder .set(Inherit.class , QuxSerializer.class );// Now contains: [BarParser,BazSerializer,QuxSerializer] - Parameters:
values- The serializers to set in this group.- Returns:
- This object.
- Throws:
IllegalArgumentException- If one or more values do not extend fromSerializeror named"Inherit" .
-
toString
-
build
Builds the serializer set.- Returns:
- A new
SerializerSet.
-