Class ParserSet.Builder

java.lang.Object
org.apache.juneau.marshall.parser.ParserSet.Builder
All Implemented Interfaces:
BeanStoreOverridable<ParserSet.Builder>
Enclosing class:
ParserSet

public static class ParserSet.Builder extends Object implements BeanStoreOverridable<ParserSet.Builder>
Builder class.
  • Constructor Details

    • Builder

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

      protected Builder(ParserSet.Builder copyFrom)
      Clone an existing parser group builder.

      Parser builders will be cloned during this process.

      Parameters:
      copyFrom - The parser group that we're copying settings and parsers from.
      Cannot be null.
    • Builder

      protected Builder(ParserSet copyFrom)
      Clone an existing parser group.
      Parameters:
      copyFrom - The parser group that we're copying settings and parsers from.
      Cannot be null.
  • Method Details

    • beanStore

      public BeanStore beanStore()
      Returns the bean store used by this builder.
      Returns:
      The bean store used by this builder.
    • overridingBeanStore

      Installs the supplied BeanStore as the overridingParent of this builder's bean store.

      Wraps the current beanStore() in a fresh BasicBeanStore whose overridingParent is the supplied store, so test-time overrides win over the builder's regular bean lookups during construction-time reflective injection. Passing null is a no-op.

      Specified by:
      overridingBeanStore in interface BeanStoreOverridable<ParserSet.Builder>
      Parameters:
      store - The override layer. Can be null (no-op).
      Returns:
      This object.
      Since:
      10.0.0
    • add

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

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

      The ParserSet.NoInherit class can be used to clear out the existing list of parsers before adding the new entries.

      Example:

      ParserSet.Builder builder = ParserSet.create(); // Create an empty builder. builder.add(FooParser.class); // Now contains: [FooParser] builder.add(BarParser.class, BazParser.class); // Now contains: [BarParser,BazParser,FooParser] builder.add(NoInherit.class, QuxParser.class); // Now contains: [QuxParser]

      Parameters:
      values - The parsers to add to this group.
      Returns:
      This object.
      Throws:
      IllegalArgumentException - If one or more values do not extend from Parser.
    • add

      public ParserSet.Builder add(Parser... s)
      Registers the specified parsers with this group.

      When passing in pre-instantiated parsers to this group, applying properties and transforms to the group do not affect them.

      Parameters:
      s - The parsers to append to this group.
      Returns:
      This object.
    • apply

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

      Associates an existing bean context builder with all parser builders in this group.
      Parameters:
      value - The bean context builder to associate.
      Can be null (clears any previously-associated bean context builder).
      Returns:
      This object.
    • marshallingContext

      Applies an operation to the bean context builder.
      Parameters:
      operation - The operation to apply.
      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 parser 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 parser builder in this group.
    • clear

      Clears out any existing parsers in this group.
      Returns:
      This object.
    • copy

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

      public <B extends Parser.Builder<?>> ParserSet.Builder forEach(Class<B> type, Consumer<B> action)
      Performs an action on all parser builders of the specified type in this group.
      Type Parameters:
      B - The parser builder type.
      Parameters:
      type - The parser builder type.
      action - The action to perform.
      Returns:
      This object.
    • forEach

      Performs an action on all parser builders in this group.
      Parameters:
      action - The action to perform.
      Returns:
      This object.
    • forEachISP

      Performs an action on all output stream parser builders in this group.
      Parameters:
      action - The action to perform.
      Returns:
      This object.
    • forEachRP

      Performs an action on all writer parser builders in this group.
      Parameters:
      action - The action to perform.
      Returns:
      This object.
    • impl

      public ParserSet.Builder impl(Object value)
      Overrides the bean returned by the build() method with a pre-built instance.
      Parameters:
      value - The pre-built instance.
      Can be null (clears the override; build() constructs a new instance).
      Returns:
      This object.
    • inner

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

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

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

      Existing values are overwritten.

      The ParserSet.Inherit class can be used to insert existing entries in this group into the position specified.

      Example:

      ParserSet.Builder builder = ParserSet.create(); // Create an empty builder. builder.set(FooParser.class); // Now contains: [FooParser] builder.set(BarParser.class, BazParser.class); // Now contains: [BarParser,BazParser] builder.set(Inherit.class, QuxParser.class); // Now contains: [BarParser,BazParser,QuxParser]

      Parameters:
      values - The parsers to set in this group.
      Returns:
      This object.
      Throws:
      IllegalArgumentException - If one or more values do not extend from Parser or named "Inherit".
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • build

      public ParserSet build()
      Builds the parser set.
      Returns:
      A new ParserSet.