Class JsonParser.Builder<SELF extends JsonParser.Builder<SELF>>

Direct Known Subclasses:
Json5Parser.Builder
Enclosing class:
JsonParser

public static class JsonParser.Builder<SELF extends JsonParser.Builder<SELF>> extends ReaderParser.Builder<SELF>
Builder class.

Unlike the abstract context builders, this builder is concrete and generic: it terminates the CRTP recursion via the leaf-free new Builder<>() pattern (see JsonParser.create() / JsonParser.copy()) rather than via a separate concrete DefaultBuilder leaf.

  • Constructor Details

    • Builder

      protected Builder()
      Constructor, default settings.
    • Builder

      protected Builder(JsonParser.Builder<?> copyFrom)
      Copy constructor.
      Parameters:
      copyFrom - The builder to copy from.
      Cannot be null.
    • Builder

      protected Builder(JsonParser copyFrom)
      Copy constructor.
      Parameters:
      copyFrom - The bean to copy from.
      Cannot be null.
  • Method Details

    • build

      public JsonParser build()
      Description copied from class: Context.Builder
      Build the object.
      Overrides:
      build in class ReaderParser.Builder<SELF extends JsonParser.Builder<SELF>>
      Returns:
      The built object.
    • copy

      public SELF copy()
      Description copied from class: Context.Builder
      Copy creator.
      Specified by:
      copy in class ReaderParser.Builder<SELF extends JsonParser.Builder<SELF>>
      Returns:
      A new mutable copy of this builder.
    • hashKey

      public HashKey hashKey()
      Description copied from class: Context.Builder
      Returns the hashkey of this builder.

      Used to return previously instantiated context beans that have matching hashkeys. The HashKey object is suitable for use as a hashmap key of a map of context beans. A context bean is considered equivalent if the HashKey.equals(Object) method is the same.

      Overrides:
      hashKey in class ReaderParser.Builder<SELF extends JsonParser.Builder<SELF>>
      Returns:
      The hashkey of this builder.
    • validateEnd

      public SELF validateEnd()
      Validate end.

      When enabled, after parsing a POJO from the input, verifies that the remaining input in the stream consists of only comments or whitespace.

      Example:

      // Create a parser that validates that there's no garbage at the end of the input. ReaderParser parser = JsonParser. .create() .validateEnd() .build(); // Should fail because input has multiple POJOs. String json = "{foo:'bar'}{baz:'qux'}"; MyBean myBean =parser.read(json, MyBean.class);

      Token streams: this setting is not honored by readTokens — the cursor leaves end-of-input checking to the caller.

      Returns:
      This object.
    • validateEnd

      public SELF validateEnd(boolean value)
      Same as validateEnd() but allows you to explicitly specify the value.
      Parameters:
      value - The value for this setting.
      Returns:
      This object.