Package org.dominokit.jacksonapt
Class DefaultJsonSerializationContext.Builder
java.lang.Object
org.dominokit.jacksonapt.DefaultJsonSerializationContext.Builder
- Direct Known Subclasses:
DefaultJsonSerializationContext.DefaultBuilder
- Enclosing class:
- DefaultJsonSerializationContext
public static class DefaultJsonSerializationContext.Builder
extends java.lang.Object
Builder for
JsonSerializationContext. To override default settings globally, you can extend this class, modify the
default settings inside the constructor and tell the compiler to use your builder instead in your gwt.xml file :
<replace-with class="your.package.YourBuilder">
<when-type-assignable class="org.dominokit.jacksonapt.JsonSerializationContext.Builder" />
</replace-with>
-
Field Summary
Fields Modifier and Type Field Description protected booleanindentprotected booleanorderMapEntriesByKeysprotected booleanserializeNullsprotected booleanuseEqualityForObjectIdprotected booleanwrapExceptionsprotected booleanwrapRootValueprotected booleanwriteCharArraysAsJsonArraysprotected booleanwriteDateKeysAsTimestampsprotected booleanwriteDatesAsTimestampsprotected booleanwriteEmptyJsonArraysprotected booleanwriteNullMapValuesprotected booleanwriteSingleElemArraysUnwrapped -
Constructor Summary
Constructors Constructor Description Builder()Deprecated. -
Method Summary
Modifier and Type Method Description JsonSerializationContextbuild()DefaultJsonSerializationContext.Builderindent(boolean indent)Feature that allows enabling (or disabling) indentation for the underlying writer.DefaultJsonSerializationContext.BuilderorderMapEntriesByKeys(boolean orderMapEntriesByKeys)Feature that determines whetherMapentries are first sorted by key before serialization or not: if enabled, additional sorting step is performed if necessary (not necessary forSortedMaps), if disabled, no additional sorting is needed.DefaultJsonSerializationContext.BuilderserializeNulls(boolean serializeNulls)Sets whether object members are serialized when their value is null.DefaultJsonSerializationContext.BuilderuseEqualityForObjectId(boolean useEqualityForObjectId)Determines whether Object Identity is compared using true JVM-level identity of Object (false); or,equals()method.DefaultJsonSerializationContext.BuilderwrapExceptions(boolean wrapExceptions)Feature that determines whether gwt-jackson code should catch and wrapRuntimeExceptions (but neverErrors!) to add additional information about location (within input) of problem or not.DefaultJsonSerializationContext.BuilderwrapRootValue(boolean wrapRootValue)Feature that can be enabled to make root value (usually JSON Object but can be any type) wrapped within a single property JSON object, where key as the "root name", as determined by annotation introspector or fallback (non-qualified class name).DefaultJsonSerializationContext.BuilderwriteCharArraysAsJsonArrays(boolean writeCharArraysAsJsonArrays)Feature that determines how typechar[]is serialized: when enabled, will be serialized as an explict JSON array (with single-character Strings as values); when disabled, defaults to serializing them as Strings (which is more compact).DefaultJsonSerializationContext.BuilderwriteDateKeysAsTimestamps(boolean writeDateKeysAsTimestamps)Feature that determines whetherDates andTimestamps used asMapkeys are serialized as timestamps or as textual values.DefaultJsonSerializationContext.BuilderwriteDatesAsTimestamps(boolean writeDatesAsTimestamps)Determines whetherDateandTimestampvalues are to be serialized as numeric timestamps (true; the default), or as textual representation.DefaultJsonSerializationContext.BuilderwriteEmptyJsonArrays(boolean writeEmptyJsonArrays)Feature that determines whether Container properties (POJO properties with declared value of Collection or array; i.e.DefaultJsonSerializationContext.BuilderwriteNullMapValues(boolean writeNullMapValues)Feature that determines whether Map entries with null values are to be serialized (true) or not (false).DefaultJsonSerializationContext.BuilderwriteSingleElemArraysUnwrapped(boolean writeSingleElemArraysUnwrapped)Feature added for interoperability, to work with oddities of so-called "BadgerFish" convention.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
useEqualityForObjectId
protected boolean useEqualityForObjectId -
serializeNulls
protected boolean serializeNulls -
writeDatesAsTimestamps
protected boolean writeDatesAsTimestamps -
writeDateKeysAsTimestamps
protected boolean writeDateKeysAsTimestamps -
indent
protected boolean indent -
wrapRootValue
protected boolean wrapRootValue -
writeCharArraysAsJsonArrays
protected boolean writeCharArraysAsJsonArrays -
writeNullMapValues
protected boolean writeNullMapValues -
writeEmptyJsonArrays
protected boolean writeEmptyJsonArrays -
orderMapEntriesByKeys
protected boolean orderMapEntriesByKeys -
writeSingleElemArraysUnwrapped
protected boolean writeSingleElemArraysUnwrapped -
wrapExceptions
protected boolean wrapExceptions
-
-
Constructor Details
-
Builder
@Deprecated public Builder()Deprecated.UseDefaultJsonSerializationContext.builder()instead. This constructor will be made protected in v1.0.
-
-
Method Details
-
useEqualityForObjectId
public DefaultJsonSerializationContext.Builder useEqualityForObjectId(boolean useEqualityForObjectId)Determines whether Object Identity is compared using true JVM-level identity of Object (false); or,equals()method. Latter is sometimes useful when dealing with Database-bound objects with ORM libraries (like Hibernate).Option is disabled by default; meaning that strict identity is used, not
equals()- Parameters:
useEqualityForObjectId- true if should useEqualityForObjectId- Returns:
- the builder
-
serializeNulls
Sets whether object members are serialized when their value is null. This has no impact on array elements. The default is true.- Parameters:
serializeNulls- true if should serializeNulls- Returns:
- the builder
-
writeDatesAsTimestamps
public DefaultJsonSerializationContext.Builder writeDatesAsTimestamps(boolean writeDatesAsTimestamps)Determines whetherDateandTimestampvalues are to be serialized as numeric timestamps (true; the default), or as textual representation.If textual representation is used, the actual format is Option is enabled by default.
- Parameters:
writeDatesAsTimestamps- true if should writeDatesAsTimestamps- Returns:
- the builder
-
writeDateKeysAsTimestamps
public DefaultJsonSerializationContext.Builder writeDateKeysAsTimestamps(boolean writeDateKeysAsTimestamps)Feature that determines whetherDates andTimestamps used asMapkeys are serialized as timestamps or as textual values.If textual representation is used, the actual format is Option is disabled by default.
- Parameters:
writeDateKeysAsTimestamps- true if should writeDateKeysAsTimestamps- Returns:
- the builder
-
indent
Feature that allows enabling (or disabling) indentation for the underlying writer.Feature is disabled by default.
- Parameters:
indent- true if should indent- Returns:
- the builder
-
wrapRootValue
Feature that can be enabled to make root value (usually JSON Object but can be any type) wrapped within a single property JSON object, where key as the "root name", as determined by annotation introspector or fallback (non-qualified class name).Feature is disabled by default.
- Parameters:
wrapRootValue- true if should wrapRootValue- Returns:
- the builder
-
writeCharArraysAsJsonArrays
public DefaultJsonSerializationContext.Builder writeCharArraysAsJsonArrays(boolean writeCharArraysAsJsonArrays)Feature that determines how typechar[]is serialized: when enabled, will be serialized as an explict JSON array (with single-character Strings as values); when disabled, defaults to serializing them as Strings (which is more compact).Feature is disabled by default.
- Parameters:
writeCharArraysAsJsonArrays- true if should writeCharArraysAsJsonArrays- Returns:
- the builder
-
writeNullMapValues
Feature that determines whether Map entries with null values are to be serialized (true) or not (false).Feature is enabled by default.
- Parameters:
writeNullMapValues- true if should writeNullMapValues- Returns:
- the builder
-
writeEmptyJsonArrays
Feature that determines whether Container properties (POJO properties with declared value of Collection or array; i.e. things that produce JSON arrays) that are empty (have no elements) will be serialized as empty JSON arrays (true), or suppressed from output (false).Note that this does not change behavior of
Maps, or "Collection-like" types.Feature is enabled by default.
- Parameters:
writeEmptyJsonArrays- true if should writeEmptyJsonArrays- Returns:
- the builder
-
orderMapEntriesByKeys
public DefaultJsonSerializationContext.Builder orderMapEntriesByKeys(boolean orderMapEntriesByKeys)Feature that determines whetherMapentries are first sorted by key before serialization or not: if enabled, additional sorting step is performed if necessary (not necessary forSortedMaps), if disabled, no additional sorting is needed.Feature is disabled by default.
- Parameters:
orderMapEntriesByKeys- true if should orderMapEntriesByKeys- Returns:
- the builder
-
writeSingleElemArraysUnwrapped
public DefaultJsonSerializationContext.Builder writeSingleElemArraysUnwrapped(boolean writeSingleElemArraysUnwrapped)Feature added for interoperability, to work with oddities of so-called "BadgerFish" convention. Feature determines handling of single elementCollections and arrays: if enabled,Collections and arrays that contain exactly one element will be serialized as if that element itself was serialized.
When enabled, a POJO with array that normally looks like this:{ "arrayProperty" : [ 1 ] }will instead be serialized as{ "arrayProperty" : 1 }Note that this feature is counterpart to
Feature is disabled by default, so that no special handling is done.DefaultJsonDeserializationContext.Builder.acceptSingleValueAsArray(boolean)(that is, usually both are enabled, or neither is).- Parameters:
writeSingleElemArraysUnwrapped- true if should writeSingleElemArraysUnwrapped- Returns:
- the builder
-
wrapExceptions
Feature that determines whether gwt-jackson code should catch and wrapRuntimeExceptions (but neverErrors!) to add additional information about location (within input) of problem or not. If enabled, exceptions will be caught and re-thrown; this can be convenient both in that all exceptions will be checked and declared, and so there is more contextual information. However, sometimes calling application may just want "raw" unchecked exceptions passed as is.
Feature is enabled by default.- Parameters:
wrapExceptions- true if should wrapExceptions- Returns:
- the builder
-
build
-
DefaultJsonSerializationContext.builder()instead.