Record Class JsonConfig

java.lang.Object
java.lang.Record
net.luis.utils.io.data.json.JsonConfig
Record Components:
strict - Whether to use strict json parsing when reading (read-only)
prettyPrint - Whether to pretty print the json (write-only)
indent - The string to use for indentation (write-only)
simplifyArrays - Whether to simplify json arrays (write-only)
maxArraySimplificationSize - The maximum size of a json array to simplify (write-only)
simplifyObjects - Whether to simplify json objects (write-only)
maxObjectSimplificationSize - The maximum size of a json object to simplify (write-only)
charset - The charset to use for reading and writing

public record JsonConfig(@ReadOnly boolean strict, @WriteOnly boolean prettyPrint, @WriteOnly("prettyPrint") @NotNull String indent, @WriteOnly("prettyPrint") boolean simplifyArrays, @WriteOnly("simplifyArrays") int maxArraySimplificationSize, @WriteOnly("prettyPrint") boolean simplifyObjects, @WriteOnly("simplifyObjects") int maxObjectSimplificationSize, @NotNull Charset charset) extends Record
Configuration for reading and writing json elements.
  • Field Details

    • strict

      private final boolean strict
      The field for the strict record component.
    • prettyPrint

      private final boolean prettyPrint
      The field for the prettyPrint record component.
    • indent

      @NotNull private final @NotNull String indent
      The field for the indent record component.
    • simplifyArrays

      private final boolean simplifyArrays
      The field for the simplifyArrays record component.
    • maxArraySimplificationSize

      private final int maxArraySimplificationSize
      The field for the maxArraySimplificationSize record component.
    • simplifyObjects

      private final boolean simplifyObjects
      The field for the simplifyObjects record component.
    • maxObjectSimplificationSize

      private final int maxObjectSimplificationSize
      The field for the maxObjectSimplificationSize record component.
    • charset

      @NotNull private final @NotNull Charset charset
      The field for the charset record component.
    • DEFAULT

      public static final JsonConfig DEFAULT
      The default json configuration.
      Strict: true
      Pretty print: true
      Indent: "\t"
      Simplify arrays: true
      Max array simplification size: 10
      Simplify objects: true
      Max object simplification size: 1
      Charset: UTF-8
  • Constructor Details

    • JsonConfig

      public JsonConfig(boolean strict, boolean prettyPrint, @NotNull @NotNull String indent, boolean simplifyArrays, int maxArraySimplificationSize, boolean simplifyObjects, int maxObjectSimplificationSize, @NotNull @NotNull Charset charset)
      Constructs a new json configuration.
      Parameters:
      strict - Whether to use strict json parsing when reading (read-only)
      prettyPrint - Whether to pretty print the json (write-only)
      indent - The string to use for indentation (write-only)
      simplifyArrays - Whether to simplify json arrays (write-only)
      maxArraySimplificationSize - The maximum size of a json array to simplify (write-only)
      simplifyObjects - Whether to simplify json objects (write-only)
      maxObjectSimplificationSize - The maximum size of a json object to simplify (write-only)
      charset - The charset to use for reading and writing
      Throws:
      NullPointerException - If the indent or charset is null
      IllegalArgumentException - If the max array or object simplification size is less than 1 and the corresponding simplification is enabled
  • Method Details

    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • strict

      public boolean strict()
      Returns the value of the strict record component.
      Returns:
      the value of the strict record component
    • prettyPrint

      public boolean prettyPrint()
      Returns the value of the prettyPrint record component.
      Returns:
      the value of the prettyPrint record component
    • indent

      @NotNull public @NotNull String indent()
      Returns the value of the indent record component.
      Returns:
      the value of the indent record component
    • simplifyArrays

      public boolean simplifyArrays()
      Returns the value of the simplifyArrays record component.
      Returns:
      the value of the simplifyArrays record component
    • maxArraySimplificationSize

      public int maxArraySimplificationSize()
      Returns the value of the maxArraySimplificationSize record component.
      Returns:
      the value of the maxArraySimplificationSize record component
    • simplifyObjects

      public boolean simplifyObjects()
      Returns the value of the simplifyObjects record component.
      Returns:
      the value of the simplifyObjects record component
    • maxObjectSimplificationSize

      public int maxObjectSimplificationSize()
      Returns the value of the maxObjectSimplificationSize record component.
      Returns:
      the value of the maxObjectSimplificationSize record component
    • charset

      @NotNull public @NotNull Charset charset()
      Returns the value of the charset record component.
      Returns:
      the value of the charset record component