Class SerializerSet.Builder

java.lang.Object
org.apache.juneau.BeanBuilder<SerializerSet>
org.apache.juneau.serializer.SerializerSet.Builder
Enclosing class:
SerializerSet

public static class SerializerSet.Builder extends BeanBuilder<SerializerSet>
Builder class.
  • Constructor Details

    • Builder

      protected Builder(BeanStore beanStore)
      Create an empty serializer group builder.
      Parameters:
      beanStore - The bean store to use for creating beans.
    • Builder

      protected Builder(SerializerSet copyFrom)
      Clone an existing serializer group.
      Parameters:
      copyFrom - The serializer group that we're copying settings and serializers from.
    • Builder

      protected Builder(SerializerSet.Builder copyFrom)
      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.
  • Method Details

    • buildDefault

      Description copied from class: BeanBuilder
      Creates the bean when the bean type is null or is the default value.
      Overrides:
      buildDefault in class BeanBuilder<SerializerSet>
      Returns:
      A new bean.
    • copy

      Makes a copy of this builder.
      Returns:
      A new copy of this builder.
    • beanContext

      Associates an existing bean context builder with all serializer builders in this group.
      Parameters:
      value - The bean contest builder to associate.
      Returns:
      This object.
    • beanContext

      Applies an operation to the bean context builder.
      Parameters:
      operation - The operation to apply.
      Returns:
      This object.
    • add

      public SerializerSet.Builder add(Class<?>... values)
      Adds the specified serializers to this group.

      Entries are added in-order to the beginning of the list in the group.

      The SerializerSet.NoInherit class 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 from Serializer.
    • set

      public SerializerSet.Builder set(Class<?>... values)
      Sets the specified serializers for this group.

      Existing values are overwritten.

      The SerializerSet.Inherit class 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 from Serializer or named "Inherit".
    • 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.
    • clear

      Clears out any existing serializers in this group.
      Returns:
      This object.
    • canApply

      public boolean canApply(AnnotationWorkList work)
      Returns true 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.
    • apply

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

      Performs an action on all 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.
    • forEachOSS

      Performs an action on all output stream serializer builders in this group.
      Parameters:
      action - The action to perform.
      Returns:
      This object.
    • 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.
    • inner

      public List<Object> inner()
      Returns direct access to the Serializer and Serializer.Builder objects 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 Serializer and Serializer.Builder objects.

      Returns:
      The inner list of entries in this builder.
    • impl

      Description copied from class: BeanBuilder
      Overrides the bean returned by the BeanBuilder.build() method.

      Use this method if you want this builder to return an already-instantiated bean.

      Overrides:
      impl in class BeanBuilder<SerializerSet>
      Parameters:
      value - The setting value.
      Returns:
      This object.
    • type

      public SerializerSet.Builder type(Class<?> value)
      Description copied from class: BeanBuilder
      Overrides the bean type produced by the BeanBuilder.build() method.

      Use this method if you want to instantiated a bean subclass.

      Overrides:
      type in class BeanBuilder<SerializerSet>
      Parameters:
      value - The setting value.
      Returns:
      This object.
    • toString

      public String toString()
      Overrides:
      toString in class Object