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 Summary
FieldsModifier and TypeFieldDescriptionprivate final @NotNull CharsetThe field for thecharsetrecord component.static final JsonConfigThe 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-8private final @NotNull StringThe field for theindentrecord component.private final intThe field for themaxArraySimplificationSizerecord component.private final intThe field for themaxObjectSimplificationSizerecord component.private final booleanThe field for theprettyPrintrecord component.private final booleanThe field for thesimplifyArraysrecord component.private final booleanThe field for thesimplifyObjectsrecord component.private final booleanThe field for thestrictrecord component. -
Constructor Summary
ConstructorsConstructorDescriptionJsonConfig(boolean strict, boolean prettyPrint, @NotNull String indent, boolean simplifyArrays, int maxArraySimplificationSize, boolean simplifyObjects, int maxObjectSimplificationSize, @NotNull Charset charset) Constructs a new json configuration. -
Method Summary
Modifier and TypeMethodDescription@NotNull Charsetcharset()Returns the value of thecharsetrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.@NotNull Stringindent()Returns the value of theindentrecord component.intReturns the value of themaxArraySimplificationSizerecord component.intReturns the value of themaxObjectSimplificationSizerecord component.booleanReturns the value of theprettyPrintrecord component.booleanReturns the value of thesimplifyArraysrecord component.booleanReturns the value of thesimplifyObjectsrecord component.booleanstrict()Returns the value of thestrictrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
strict
private final boolean strictThe field for thestrictrecord component. -
prettyPrint
private final boolean prettyPrintThe field for theprettyPrintrecord component. -
indent
The field for theindentrecord component. -
simplifyArrays
private final boolean simplifyArraysThe field for thesimplifyArraysrecord component. -
maxArraySimplificationSize
private final int maxArraySimplificationSizeThe field for themaxArraySimplificationSizerecord component. -
simplifyObjects
private final boolean simplifyObjectsThe field for thesimplifyObjectsrecord component. -
maxObjectSimplificationSize
private final int maxObjectSimplificationSizeThe field for themaxObjectSimplificationSizerecord component. -
charset
The field for thecharsetrecord component. -
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 nullIllegalArgumentException- If the max array or object simplification size is less than 1 and the corresponding simplification is enabled
-
-
Method Details
-
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
strict
public boolean strict()Returns the value of thestrictrecord component.- Returns:
- the value of the
strictrecord component
-
prettyPrint
public boolean prettyPrint()Returns the value of theprettyPrintrecord component.- Returns:
- the value of the
prettyPrintrecord component
-
indent
Returns the value of theindentrecord component.- Returns:
- the value of the
indentrecord component
-
simplifyArrays
public boolean simplifyArrays()Returns the value of thesimplifyArraysrecord component.- Returns:
- the value of the
simplifyArraysrecord component
-
maxArraySimplificationSize
public int maxArraySimplificationSize()Returns the value of themaxArraySimplificationSizerecord component.- Returns:
- the value of the
maxArraySimplificationSizerecord component
-
simplifyObjects
public boolean simplifyObjects()Returns the value of thesimplifyObjectsrecord component.- Returns:
- the value of the
simplifyObjectsrecord component
-
maxObjectSimplificationSize
public int maxObjectSimplificationSize()Returns the value of themaxObjectSimplificationSizerecord component.- Returns:
- the value of the
maxObjectSimplificationSizerecord component
-
charset
Returns the value of thecharsetrecord component.- Returns:
- the value of the
charsetrecord component
-