Class SerializationConfig
- All Implemented Interfaces:
ClassIntrospector.MixInResolver,Serializable
ObjectMapper, which
passes an immutable instance for serialization process to
SerializerProvider and SerializerFactory
(either directly, or through ObjectWriter.
Note that instances are considered immutable and as such no copies should need to be created for sharing; all copying is done with "fluent factory" methods.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ConstructorDetectorprotected final PrettyPrinterIf "default pretty-printing" is enabled, it will create the instance from this blueprint object.protected final FilterProviderObject used for resolving filter ids to filter instances.protected final intStates ofFormatFeatures to enable/disable.protected final intBitflag ofFormatFeatures to enable/disableprotected final intStates ofJsonGenerator.Features to enable/disable.protected final intBitflag ofJsonGenerator.Features to enable/disableprotected final intSet ofSerializationFeatures enabled.protected static final PrettyPrinterFields inherited from class com.fasterxml.jackson.databind.cfg.MapperConfigBase
_attributes, _configOverrides, _datatypeFeatures, _mixIns, _rootName, _rootNames, _subtypeResolver, _view, EMPTY_OVERRIDEFields inherited from class com.fasterxml.jackson.databind.cfg.MapperConfig
_base, _mapperFeatures, EMPTY_FORMAT, EMPTY_INCLUDE -
Constructor Summary
ConstructorsModifierConstructorDescriptionSerializationConfig(BaseSettings base, SubtypeResolver str, SimpleMixInResolver mixins, RootNameLookup rootNames, ConfigOverrides configOverrides) Deprecated.since 2.14SerializationConfig(BaseSettings base, SubtypeResolver str, SimpleMixInResolver mixins, RootNameLookup rootNames, ConfigOverrides configOverrides, DatatypeFeatures datatypeFeatures) Constructor used by ObjectMapper to create default configuration object instance.protectedSerializationConfig(SerializationConfig src, PrettyPrinter defaultPP) protectedSerializationConfig(SerializationConfig src, ConstructorDetector ctorDetector) protectedSerializationConfig(SerializationConfig src, ContextAttributes attrs) protectedSerializationConfig(SerializationConfig src, DatatypeFeatures dtFeatures) protectedSerializationConfig(SerializationConfig src, SimpleMixInResolver mixins) protectedSerializationConfig(SerializationConfig src, SubtypeResolver str, SimpleMixInResolver mixins, RootNameLookup rootNames, ConfigOverrides configOverrides) Copy-constructor used for making a copy to be used by newObjectMapper. -
Method Summary
Modifier and TypeMethodDescriptionprotected final SerializationConfig_with(DatatypeFeatures dtFeatures) protected final SerializationConfig_withBase(BaseSettings newBase) protected final SerializationConfig_withMapperFeatures(long mapperFeatures) Accessor for configured blueprint "default"PrettyPrinterto use, if default pretty-printing is enabled.Method for getting provider used for locating filters given id (which is usually provided with filter annotations).final intDeprecated.Since 2.7 useMapperConfigBase.getDefaultPropertyInclusion()insteadfinal booleanhasSerializationFeatures(int featureMask) "Bulk" access method for checking that all features specified by mask are enabled.voidMethod called byObjectMapperandObjectWriterto modify thoseJsonGenerator.Featuresettings that have been configured via this config instance.introspect(JavaType type) Method that will introspect full bean properties for the purpose of building a bean serializerfinal booleanisEnabled(JsonGenerator.Feature f, JsonFactory factory) Accessor method that first checks if we have any overrides for feature, and only if not, checks state of passed-in factory.final booleanisEnabled(DatatypeFeature feature) Accessor for checking whether giveDatatypeFeatureis enabled or not.final booleanisEnabled(SerializationFeature feature) Accessor for checking whether giveSerializationFeatureis enabled or not.booleanAccessor for checking whether configuration indicates that "root wrapping" (use of an extra property/name pair at root level) is expected or not.with(FormatFeature feature) Fluent factory method that will construct and return a new configuration object instance with specified feature enabled.with(JsonGenerator.Feature feature) Fluent factory method that will construct and return a new configuration object instance with specified feature enabled.with(ConstructorDetector ctorDetector) with(ContextAttributes attrs) Method for constructing an instance that has specified contextual attributes.with(SubtypeResolver str) Method for constructing and returning a new instance with differentSubtypeResolverto use.with(SerializationFeature feature) Fluent factory method that will construct and return a new configuration object instance with specified feature enabled.with(SerializationFeature first, SerializationFeature... features) Fluent factory method that will construct and return a new configuration object instance with specified features enabled.with(DateFormat df) In addition to constructing instance with specified date format, will enable or disableSerializationFeature.WRITE_DATES_AS_TIMESTAMPS(enable if format set as null; disable if non-null)withFeatures(FormatFeature... features) Fluent factory method that will construct and return a new configuration object instance with specified features enabled.withFeatures(JsonGenerator.Feature... features) Fluent factory method that will construct and return a new configuration object instance with specified features enabled.withFeatures(SerializationFeature... features) Fluent factory method that will construct and return a new configuration object instance with specified features enabled.withFilters(FilterProvider filterProvider) without(FormatFeature feature) Fluent factory method that will construct and return a new configuration object instance with specified feature disabled.without(JsonGenerator.Feature feature) Fluent factory method that will construct and return a new configuration object instance with specified feature disabled.without(SerializationFeature feature) Fluent factory method that will construct and return a new configuration object instance with specified feature disabled.without(SerializationFeature first, SerializationFeature... features) Fluent factory method that will construct and return a new configuration object instance with specified features disabled.withoutFeatures(FormatFeature... features) Fluent factory method that will construct and return a new configuration object instance with specified features disabled.withoutFeatures(JsonGenerator.Feature... features) Fluent factory method that will construct and return a new configuration object instance with specified features disabled.withoutFeatures(SerializationFeature... features) Fluent factory method that will construct and return a new configuration object instance with specified features disabled.Deprecated.Since 2.9; not needed any morewithRootName(PropertyName rootName) Method for constructing and returning a new instance with different root name to use (none, if null).Method for constructing and returning a new instance with different view to use.Methods inherited from class com.fasterxml.jackson.databind.cfg.MapperConfigBase
_datatypeFeatures, copy, findConfigOverride, findMixInClassFor, findRootName, findRootName, getActiveView, getAttributes, getConfigOverride, getDatatypeFeatures, getDefaultInclusion, getDefaultMergeable, getDefaultMergeable, getDefaultPropertyFormat, getDefaultPropertyIgnorals, getDefaultPropertyIgnorals, getDefaultPropertyInclusion, getDefaultPropertyInclusion, getDefaultPropertyInclusions, getDefaultSetterInfo, getDefaultVisibilityChecker, getDefaultVisibilityChecker, getFullRootName, getRootName, getSubtypeResolver, mixInCount, with, with, with, with, with, with, with, with, with, with, with, with, with, with, with, withAppendedAnnotationIntrospector, withAttribute, withAttributes, withFeatures, withInsertedAnnotationIntrospector, without, without, withoutAttribute, withoutFeatures, withRootNameMethods inherited from class com.fasterxml.jackson.databind.cfg.MapperConfig
canOverrideAccessModifiers, collectFeatureDefaults, compileString, constructSpecializedType, constructType, constructType, getAccessorNaming, getAnnotationIntrospector, getBase64Variant, getCacheProvider, getClassIntrospector, getDateFormat, getDefaultInclusion, getDefaultPropertyInclusion, getDefaultTyper, getHandlerInstantiator, getLocale, getPolymorphicTypeValidator, getPropertyNamingStrategy, getTimeZone, getTypeFactory, hasExplicitTimeZone, hasMapperFeatures, introspectClassAnnotations, introspectClassAnnotations, introspectDirectClassAnnotations, introspectDirectClassAnnotations, isAnnotationProcessingEnabled, isEnabled, shouldSortPropertiesAlphabetically, typeIdResolverInstance, typeResolverBuilderInstance
-
Field Details
-
DEFAULT_PRETTY_PRINTER
-
_filterProvider
Object used for resolving filter ids to filter instances. Non-null if explicitly defined; null by default. -
_defaultPrettyPrinter
If "default pretty-printing" is enabled, it will create the instance from this blueprint object.- Since:
- 2.6
-
_ctorDetector
- Since:
- 2.18 (only in DeserializationConfig from 2.12)
-
_serFeatures
protected final int _serFeaturesSet ofSerializationFeatures enabled. -
_generatorFeatures
protected final int _generatorFeaturesStates ofJsonGenerator.Features to enable/disable. -
_generatorFeaturesToChange
protected final int _generatorFeaturesToChangeBitflag ofJsonGenerator.Features to enable/disable -
_formatWriteFeatures
protected final int _formatWriteFeaturesStates ofFormatFeatures to enable/disable.- Since:
- 2.7
-
_formatWriteFeaturesToChange
protected final int _formatWriteFeaturesToChangeBitflag ofFormatFeatures to enable/disable- Since:
- 2.7
-
-
Constructor Details
-
SerializationConfig
public SerializationConfig(BaseSettings base, SubtypeResolver str, SimpleMixInResolver mixins, RootNameLookup rootNames, ConfigOverrides configOverrides, DatatypeFeatures datatypeFeatures) Constructor used by ObjectMapper to create default configuration object instance.- Since:
- 2.14
-
SerializationConfig
@Deprecated public SerializationConfig(BaseSettings base, SubtypeResolver str, SimpleMixInResolver mixins, RootNameLookup rootNames, ConfigOverrides configOverrides) Deprecated.since 2.14 -
SerializationConfig
protected SerializationConfig(SerializationConfig src, SubtypeResolver str, SimpleMixInResolver mixins, RootNameLookup rootNames, ConfigOverrides configOverrides) Copy-constructor used for making a copy to be used by newObjectMapper.- Since:
- 2.14
-
SerializationConfig
- Since:
- 2.1
-
SerializationConfig
- Since:
- 2.1
-
SerializationConfig
- Since:
- 2.6
-
SerializationConfig
- Since:
- 2.14
-
SerializationConfig
- Since:
- 2.18
-
-
Method Details
-
_withBase
- Specified by:
_withBasein classMapperConfigBase<SerializationFeature,SerializationConfig>
-
_withMapperFeatures
- Specified by:
_withMapperFeaturesin classMapperConfigBase<SerializationFeature,SerializationConfig>
-
_with
- Specified by:
_within classMapperConfigBase<SerializationFeature,SerializationConfig>
-
withRootName
Description copied from class:MapperConfigBaseMethod for constructing and returning a new instance with different root name to use (none, if null).Note that when a root name is set to a non-Empty String, this will automatically force use of root element wrapping with given name. If empty String passed, will disable root name wrapping; and if null used, will instead use
SerializationFeatureto determine if to use wrapping, and annotation (or default name) for actual root name to use.- Specified by:
withRootNamein classMapperConfigBase<SerializationFeature,SerializationConfig> - Parameters:
rootName- to use: if null, means "use default" (clear setting); if empty String ("") means that no root name wrapping is used; otherwise defines root name to use.
-
with
Description copied from class:MapperConfigBaseMethod for constructing and returning a new instance with differentSubtypeResolverto use.NOTE: make sure to register new instance with
ObjectMapperif directly calling this method.- Specified by:
within classMapperConfigBase<SerializationFeature,SerializationConfig>
-
withView
Description copied from class:MapperConfigBaseMethod for constructing and returning a new instance with different view to use.- Specified by:
withViewin classMapperConfigBase<SerializationFeature,SerializationConfig>
-
with
Description copied from class:MapperConfigBaseMethod for constructing an instance that has specified contextual attributes.- Specified by:
within classMapperConfigBase<SerializationFeature,SerializationConfig>
-
with
In addition to constructing instance with specified date format, will enable or disableSerializationFeature.WRITE_DATES_AS_TIMESTAMPS(enable if format set as null; disable if non-null)- Overrides:
within classMapperConfigBase<SerializationFeature,SerializationConfig>
-
with
Fluent factory method that will construct and return a new configuration object instance with specified feature enabled. -
with
Fluent factory method that will construct and return a new configuration object instance with specified features enabled. -
withFeatures
Fluent factory method that will construct and return a new configuration object instance with specified features enabled. -
without
Fluent factory method that will construct and return a new configuration object instance with specified feature disabled. -
without
Fluent factory method that will construct and return a new configuration object instance with specified features disabled. -
withoutFeatures
Fluent factory method that will construct and return a new configuration object instance with specified features disabled. -
with
Fluent factory method that will construct and return a new configuration object instance with specified feature enabled.- Since:
- 2.5
-
withFeatures
Fluent factory method that will construct and return a new configuration object instance with specified features enabled.- Since:
- 2.5
-
without
Fluent factory method that will construct and return a new configuration object instance with specified feature disabled.- Since:
- 2.5
-
withoutFeatures
Fluent factory method that will construct and return a new configuration object instance with specified features disabled.- Since:
- 2.5
-
with
Fluent factory method that will construct and return a new configuration object instance with specified feature enabled.- Since:
- 2.7
-
withFeatures
Fluent factory method that will construct and return a new configuration object instance with specified features enabled.- Since:
- 2.7
-
without
Fluent factory method that will construct and return a new configuration object instance with specified feature disabled.- Since:
- 2.7
-
withoutFeatures
Fluent factory method that will construct and return a new configuration object instance with specified features disabled.- Since:
- 2.7
-
withFilters
-
withPropertyInclusion
Deprecated.Since 2.9; not needed any moreMutant factory method for constructing a new instance with different default inclusion criteria configuration.- Since:
- 2.7
-
withDefaultPrettyPrinter
- Since:
- 2.6
-
with
- Since:
- 2.18
-
constructDefaultPrettyPrinter
-
initialize
Method called byObjectMapperandObjectWriterto modify thoseJsonGenerator.Featuresettings that have been configured via this config instance.- Since:
- 2.5
-
getSerializationInclusion
Deprecated.Since 2.7 useMapperConfigBase.getDefaultPropertyInclusion()instead -
useRootWrapping
public boolean useRootWrapping()Description copied from class:MapperConfigAccessor for checking whether configuration indicates that "root wrapping" (use of an extra property/name pair at root level) is expected or not.- Specified by:
useRootWrappingin classMapperConfig<SerializationConfig>
-
isEnabled
Accessor for checking whether giveSerializationFeatureis enabled or not.- Parameters:
feature- Feature to check- Returns:
- True if feature is enabled; false otherwise
-
isEnabled
Accessor method that first checks if we have any overrides for feature, and only if not, checks state of passed-in factory.- Since:
- 2.5
-
hasSerializationFeatures
public final boolean hasSerializationFeatures(int featureMask) "Bulk" access method for checking that all features specified by mask are enabled.- Since:
- 2.3
-
getSerializationFeatures
public final int getSerializationFeatures() -
isEnabled
Accessor for checking whether giveDatatypeFeatureis enabled or not.- Specified by:
isEnabledin classMapperConfig<SerializationConfig>- Parameters:
feature- Feature to check- Returns:
- True if feature is enabled; false otherwise
- Since:
- 2.14
-
getFilterProvider
Method for getting provider used for locating filters given id (which is usually provided with filter annotations). Will be null if no provided was set forObjectWriter(or if serialization directly called fromObjectMapper) -
getDefaultPrettyPrinter
Accessor for configured blueprint "default"PrettyPrinterto use, if default pretty-printing is enabled.NOTE: returns the "blueprint" instance, and does NOT construct an instance ready to use; call
constructDefaultPrettyPrinter()if actually usable instance is desired.- Since:
- 2.6
-
getConstructorDetector
- Specified by:
getConstructorDetectorin classMapperConfig<SerializationConfig>
-
introspect
Method that will introspect full bean properties for the purpose of building a bean serializer
-