Package org.cakelab.json.codec
Class JSONCodecConfiguration
- java.lang.Object
-
- org.cakelab.json.codec.JSONCodecConfiguration
-
public class JSONCodecConfiguration extends java.lang.Object
Configuration ofJSONCodec
s andJSONModeller
s. A configuration is intended to be used for multiple (if not all) instances of JSONCodec or JSONModeller. This class is immutable and implements a variant of the Builder Pattern.- All fields are
public final
. - For each field exists a "setter" with the same name.
- Each field "setter" creates a copy of the instance, changing the field to the given value.
JSONCodecConfiguration cfg = new JSONCodecConfiguration() .ignoreNull(true) .ignoreMissingFields(true);
Multi-Threading
Immutable.- Author:
- homac
- All fields are
-
-
Field Summary
Fields Modifier and Type Field Description java.nio.charset.Charset
charset
Character encoding of the JSON strings read from input streams.JSONFormatter
formatter
Defines the defaultJSONFormatter
used to render JSON strings.boolean
ignoreMissingFields
Codec ignores fields in the JSON string, that do not exist in the corresponding Java class.boolean
ignoreNull
Codec removes all members with null values in a given object during encoding/decoding.JSONMappingMap
mapping
Defines list of specific JSON mappings to be used by the json modeller.JSONParserFactory
parserFactory
Defines the parser factory to be used to create instances ofJSONParser
.boolean
supportClassAttribute
Considers the special attributeclass
in a JSON object as type of the compound type which contains it - much like the static memberclass
of each Java object.
-
Constructor Summary
Constructors Constructor Description JSONCodecConfiguration()
JSONCodecConfiguration(java.nio.charset.Charset charset, boolean ignoreNull, boolean ignoreMissingFields, boolean supportClassAttribute, JSONParserFactory parserFactory, JSONFormatter formatter, JSONMappingMap mapping)
JSONCodecConfiguration(JSONCodecConfiguration that)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JSONCodecConfiguration
charset(java.nio.charset.Charset charset)
JSONCodecConfiguration
formatter(JSONFormatter formatter)
JSONCodecConfiguration
ignoreMissingFields(boolean ignoreMissingFields)
JSONCodecConfiguration
ignoreNull(boolean ignoreNull)
JSONCodecConfiguration
mapping(JSONMapping<?,?> mapping)
JSONCodecConfiguration
mapping(JSONMappingMap mapping)
JSONCodecConfiguration
parserFactory(JSONParserFactory parserFactory)
JSONCodecConfiguration
supportClassAttribute(boolean supportClassAttribute)
-
-
-
Field Detail
-
charset
public final java.nio.charset.Charset charset
Character encoding of the JSON strings read from input streams.
Default:JSONDefaults.CHARSET
-
ignoreNull
public final boolean ignoreNull
Codec removes all members with null values in a given object during encoding/decoding.
Default:JSONDefaults.IGNORE_NULL
-
ignoreMissingFields
public final boolean ignoreMissingFields
Codec ignores fields in the JSON string, that do not exist in the corresponding Java class.
Default:JSONDefaults.IGNORE_MISSING_FIELDS
-
supportClassAttribute
public final boolean supportClassAttribute
Considers the special attributeclass
in a JSON object as type of the compound type which contains it - much like the static memberclass
of each Java object.
Default:JSONDefaults.SUPPORT_CLASS_ATTRIB
-
parserFactory
public final JSONParserFactory parserFactory
Defines the parser factory to be used to create instances ofJSONParser
.
Default:JSONDefaults.PARSER_FACTORY
-
formatter
public final JSONFormatter formatter
-
mapping
public final JSONMappingMap mapping
Defines list of specific JSON mappings to be used by the json modeller.
Default: empty
-
-
Constructor Detail
-
JSONCodecConfiguration
public JSONCodecConfiguration()
-
JSONCodecConfiguration
public JSONCodecConfiguration(JSONCodecConfiguration that)
-
JSONCodecConfiguration
public JSONCodecConfiguration(java.nio.charset.Charset charset, boolean ignoreNull, boolean ignoreMissingFields, boolean supportClassAttribute, JSONParserFactory parserFactory, JSONFormatter formatter, JSONMappingMap mapping)
-
-
Method Detail
-
charset
public JSONCodecConfiguration charset(java.nio.charset.Charset charset)
-
ignoreNull
public JSONCodecConfiguration ignoreNull(boolean ignoreNull)
-
ignoreMissingFields
public JSONCodecConfiguration ignoreMissingFields(boolean ignoreMissingFields)
-
supportClassAttribute
public JSONCodecConfiguration supportClassAttribute(boolean supportClassAttribute)
-
parserFactory
public JSONCodecConfiguration parserFactory(JSONParserFactory parserFactory)
-
formatter
public JSONCodecConfiguration formatter(JSONFormatter formatter)
-
mapping
public JSONCodecConfiguration mapping(JSONMappingMap mapping)
-
mapping
public JSONCodecConfiguration mapping(JSONMapping<?,?> mapping)
-
-