Class SerializationConfig
- java.lang.Object
-
- com.fasterxml.jackson.databind.cfg.MapperConfig<T>
-
- com.fasterxml.jackson.databind.cfg.MapperConfigBase<SerializationFeature,SerializationConfig>
-
- com.fasterxml.jackson.databind.SerializationConfig
-
- All Implemented Interfaces:
ClassIntrospector.MixInResolver,Serializable
public final class SerializationConfig extends MapperConfigBase<SerializationFeature,SerializationConfig> implements Serializable
Object that contains baseline configuration for serialization process. An instance is owned byObjectMapper, which passes an immutable instance for serialization process toSerializerProviderandSerializerFactory(either directly, or throughObjectWriter.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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected com.fasterxml.jackson.core.PrettyPrinter_defaultPrettyPrinterIf "default pretty-printing" is enabled, it will create the instance from this blueprint object.protected FilterProvider_filterProviderObject used for resolving filter ids to filter instances.protected int_formatWriteFeaturesStates ofFormatFeatures to enable/disable.protected int_formatWriteFeaturesToChangeBitflag ofFormatFeatures to enable/disableprotected int_generatorFeaturesStates ofJsonGenerator.Features to enable/disable.protected int_generatorFeaturesToChangeBitflag ofJsonGenerator.Features to enable/disableprotected int_serFeaturesSet ofSerializationFeatures enabled.protected static com.fasterxml.jackson.core.PrettyPrinterDEFAULT_PRETTY_PRINTER-
Fields inherited from class com.fasterxml.jackson.databind.cfg.MapperConfigBase
_attributes, _configOverrides, _mixIns, _rootName, _rootNames, _subtypeResolver, _view, EMPTY_OVERRIDE
-
Fields inherited from class com.fasterxml.jackson.databind.cfg.MapperConfig
_base, _mapperFeatures, EMPTY_FORMAT, EMPTY_INCLUDE
-
-
Constructor Summary
Constructors Modifier Constructor Description SerializationConfig(BaseSettings base, SubtypeResolver str, SimpleMixInResolver mixins, RootNameLookup rootNames, ConfigOverrides configOverrides)Constructor used by ObjectMapper to create default configuration object instance.protectedSerializationConfig(SerializationConfig src, com.fasterxml.jackson.core.PrettyPrinter defaultPP)protectedSerializationConfig(SerializationConfig src, ContextAttributes attrs)protectedSerializationConfig(SerializationConfig src, SimpleMixInResolver mixins)protectedSerializationConfig(SerializationConfig src, SimpleMixInResolver mixins, RootNameLookup rootNames, ConfigOverrides configOverrides)Copy-constructor used for making a copy to be used by newObjectMapper.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected SerializationConfig_withBase(BaseSettings newBase)protected SerializationConfig_withMapperFeatures(int mapperFeatures)com.fasterxml.jackson.core.PrettyPrinterconstructDefaultPrettyPrinter()com.fasterxml.jackson.core.PrettyPrintergetDefaultPrettyPrinter()Accessor for configured blueprint "default"PrettyPrinterto use, if default pretty-printing is enabled.FilterProvidergetFilterProvider()Method for getting provider used for locating filters given id (which is usually provided with filter annotations).intgetSerializationFeatures()com.fasterxml.jackson.annotation.JsonInclude.IncludegetSerializationInclusion()Deprecated.Since 2.7 useMapperConfigBase.getDefaultPropertyInclusion()insteadbooleanhasSerializationFeatures(int featureMask)"Bulk" access method for checking that all features specified by mask are enabled.voidinitialize(com.fasterxml.jackson.core.JsonGenerator g)Method called byObjectMapperandObjectWriterto modify thoseJsonGenerator.Featuresettings that have been configured via this config instance.<T extends BeanDescription>
Tintrospect(JavaType type)Method that will introspect full bean properties for the purpose of building a bean serializerbooleanisEnabled(com.fasterxml.jackson.core.JsonGenerator.Feature f, com.fasterxml.jackson.core.JsonFactory factory)Accessor method that first checks if we have any overrides for feature, and only if not, checks state of passed-in factory.booleanisEnabled(SerializationFeature f)booleanuseRootWrapping()Accessor for checking whether configuration indicates that "root wrapping" (use of an extra property/name pair at root level) is expected or not.SerializationConfigwith(com.fasterxml.jackson.core.FormatFeature feature)Fluent factory method that will construct and return a new configuration object instance with specified feature enabled.SerializationConfigwith(com.fasterxml.jackson.core.JsonGenerator.Feature feature)Fluent factory method that will construct and return a new configuration object instance with specified feature enabled.SerializationConfigwith(ContextAttributes attrs)Method for constructing an instance that has specified contextual attributes.SerializationConfigwith(SubtypeResolver str)Method for constructing and returning a new instance with differentSubtypeResolverto use.SerializationConfigwith(SerializationFeature feature)Fluent factory method that will construct and return a new configuration object instance with specified feature enabled.SerializationConfigwith(SerializationFeature first, SerializationFeature... features)Fluent factory method that will construct and return a new configuration object instance with specified features enabled.SerializationConfigwith(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)SerializationConfigwithDefaultPrettyPrinter(com.fasterxml.jackson.core.PrettyPrinter pp)SerializationConfigwithFeatures(com.fasterxml.jackson.core.FormatFeature... features)Fluent factory method that will construct and return a new configuration object instance with specified features enabled.SerializationConfigwithFeatures(com.fasterxml.jackson.core.JsonGenerator.Feature... features)Fluent factory method that will construct and return a new configuration object instance with specified features enabled.SerializationConfigwithFeatures(SerializationFeature... features)Fluent factory method that will construct and return a new configuration object instance with specified features enabled.SerializationConfigwithFilters(FilterProvider filterProvider)SerializationConfigwithout(com.fasterxml.jackson.core.FormatFeature feature)Fluent factory method that will construct and return a new configuration object instance with specified feature disabled.SerializationConfigwithout(com.fasterxml.jackson.core.JsonGenerator.Feature feature)Fluent factory method that will construct and return a new configuration object instance with specified feature disabled.SerializationConfigwithout(SerializationFeature feature)Fluent factory method that will construct and return a new configuration object instance with specified feature disabled.SerializationConfigwithout(SerializationFeature first, SerializationFeature... features)Fluent factory method that will construct and return a new configuration object instance with specified features disabled.SerializationConfigwithoutFeatures(com.fasterxml.jackson.core.FormatFeature... features)Fluent factory method that will construct and return a new configuration object instance with specified features disabled.SerializationConfigwithoutFeatures(com.fasterxml.jackson.core.JsonGenerator.Feature... features)Fluent factory method that will construct and return a new configuration object instance with specified features disabled.SerializationConfigwithoutFeatures(SerializationFeature... features)Fluent factory method that will construct and return a new configuration object instance with specified features disabled.SerializationConfigwithPropertyInclusion(com.fasterxml.jackson.annotation.JsonInclude.Value incl)Deprecated.Since 2.9; not needed any moreSerializationConfigwithRootName(PropertyName rootName)Method for constructing and returning a new instance with different root name to use (none, if null).SerializationConfigwithView(Class<?> view)Method for constructing and returning a new instance with different view to use.-
Methods inherited from class com.fasterxml.jackson.databind.cfg.MapperConfigBase
copy, findConfigOverride, findMixInClassFor, findRootName, findRootName, getActiveView, getAttributes, getConfigOverride, getDefaultInclusion, getDefaultMergeable, getDefaultMergeable, getDefaultPropertyFormat, getDefaultPropertyIgnorals, getDefaultPropertyIgnorals, getDefaultPropertyInclusion, getDefaultPropertyInclusion, getDefaultSetterInfo, getDefaultVisibilityChecker, getDefaultVisibilityChecker, getFullRootName, getRootName, getSubtypeResolver, mixInCount, with, with, with, with, with, with, with, with, with, with, with, withAppendedAnnotationIntrospector, withAttribute, withAttributes, withInsertedAnnotationIntrospector, without, withoutAttribute, withRootName
-
Methods inherited from class com.fasterxml.jackson.databind.cfg.MapperConfig
canOverrideAccessModifiers, collectFeatureDefaults, compileString, constructSpecializedType, constructType, constructType, getAnnotationIntrospector, getBase64Variant, getClassIntrospector, getDateFormat, getDefaultInclusion, getDefaultPropertyInclusion, getDefaultTyper, getHandlerInstantiator, getLocale, getPolymorphicTypeValidator, getPropertyNamingStrategy, getTimeZone, getTypeFactory, hasMapperFeatures, introspectClassAnnotations, introspectClassAnnotations, introspectDirectClassAnnotations, introspectDirectClassAnnotations, isAnnotationProcessingEnabled, isEnabled, shouldSortPropertiesAlphabetically, typeIdResolverInstance, typeResolverBuilderInstance
-
-
-
-
Field Detail
-
DEFAULT_PRETTY_PRINTER
protected static final com.fasterxml.jackson.core.PrettyPrinter DEFAULT_PRETTY_PRINTER
-
_filterProvider
protected final FilterProvider _filterProvider
Object used for resolving filter ids to filter instances. Non-null if explicitly defined; null by default.
-
_defaultPrettyPrinter
protected final com.fasterxml.jackson.core.PrettyPrinter _defaultPrettyPrinter
If "default pretty-printing" is enabled, it will create the instance from this blueprint object.- Since:
- 2.6
-
_serFeatures
protected final int _serFeatures
Set ofSerializationFeatures enabled.
-
_generatorFeatures
protected final int _generatorFeatures
States ofJsonGenerator.Features to enable/disable.
-
_generatorFeaturesToChange
protected final int _generatorFeaturesToChange
Bitflag ofJsonGenerator.Features to enable/disable
-
_formatWriteFeatures
protected final int _formatWriteFeatures
States ofFormatFeatures to enable/disable.- Since:
- 2.7
-
_formatWriteFeaturesToChange
protected final int _formatWriteFeaturesToChange
Bitflag ofFormatFeatures to enable/disable- Since:
- 2.7
-
-
Constructor Detail
-
SerializationConfig
public SerializationConfig(BaseSettings base, SubtypeResolver str, SimpleMixInResolver mixins, RootNameLookup rootNames, ConfigOverrides configOverrides)
Constructor used by ObjectMapper to create default configuration object instance.- Since:
- 2.9
-
SerializationConfig
protected SerializationConfig(SerializationConfig src, SimpleMixInResolver mixins, RootNameLookup rootNames, ConfigOverrides configOverrides)
Copy-constructor used for making a copy to be used by newObjectMapper.- Since:
- 2.9
-
SerializationConfig
protected SerializationConfig(SerializationConfig src, ContextAttributes attrs)
- Since:
- 2.1
-
SerializationConfig
protected SerializationConfig(SerializationConfig src, SimpleMixInResolver mixins)
- Since:
- 2.1
-
SerializationConfig
protected SerializationConfig(SerializationConfig src, com.fasterxml.jackson.core.PrettyPrinter defaultPP)
- Since:
- 2.6
-
-
Method Detail
-
_withBase
protected final SerializationConfig _withBase(BaseSettings newBase)
- Specified by:
_withBasein classMapperConfigBase<SerializationFeature,SerializationConfig>
-
_withMapperFeatures
protected final SerializationConfig _withMapperFeatures(int mapperFeatures)
- Specified by:
_withMapperFeaturesin classMapperConfigBase<SerializationFeature,SerializationConfig>
-
withRootName
public SerializationConfig withRootName(PropertyName rootName)
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
public SerializationConfig with(SubtypeResolver str)
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
public SerializationConfig withView(Class<?> view)
Description copied from class:MapperConfigBaseMethod for constructing and returning a new instance with different view to use.- Specified by:
withViewin classMapperConfigBase<SerializationFeature,SerializationConfig>
-
with
public SerializationConfig with(ContextAttributes attrs)
Description copied from class:MapperConfigBaseMethod for constructing an instance that has specified contextual attributes.- Specified by:
within classMapperConfigBase<SerializationFeature,SerializationConfig>
-
with
public SerializationConfig 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)- Overrides:
within classMapperConfigBase<SerializationFeature,SerializationConfig>
-
with
public SerializationConfig with(SerializationFeature feature)
Fluent factory method that will construct and return a new configuration object instance with specified feature enabled.
-
with
public SerializationConfig with(SerializationFeature first, SerializationFeature... features)
Fluent factory method that will construct and return a new configuration object instance with specified features enabled.
-
withFeatures
public SerializationConfig withFeatures(SerializationFeature... features)
Fluent factory method that will construct and return a new configuration object instance with specified features enabled.
-
without
public SerializationConfig without(SerializationFeature feature)
Fluent factory method that will construct and return a new configuration object instance with specified feature disabled.
-
without
public SerializationConfig without(SerializationFeature first, SerializationFeature... features)
Fluent factory method that will construct and return a new configuration object instance with specified features disabled.
-
withoutFeatures
public SerializationConfig withoutFeatures(SerializationFeature... features)
Fluent factory method that will construct and return a new configuration object instance with specified features disabled.
-
with
public SerializationConfig with(com.fasterxml.jackson.core.JsonGenerator.Feature feature)
Fluent factory method that will construct and return a new configuration object instance with specified feature enabled.- Since:
- 2.5
-
withFeatures
public SerializationConfig withFeatures(com.fasterxml.jackson.core.JsonGenerator.Feature... features)
Fluent factory method that will construct and return a new configuration object instance with specified features enabled.- Since:
- 2.5
-
without
public SerializationConfig without(com.fasterxml.jackson.core.JsonGenerator.Feature feature)
Fluent factory method that will construct and return a new configuration object instance with specified feature disabled.- Since:
- 2.5
-
withoutFeatures
public SerializationConfig withoutFeatures(com.fasterxml.jackson.core.JsonGenerator.Feature... features)
Fluent factory method that will construct and return a new configuration object instance with specified features disabled.- Since:
- 2.5
-
with
public SerializationConfig with(com.fasterxml.jackson.core.FormatFeature feature)
Fluent factory method that will construct and return a new configuration object instance with specified feature enabled.- Since:
- 2.7
-
withFeatures
public SerializationConfig withFeatures(com.fasterxml.jackson.core.FormatFeature... features)
Fluent factory method that will construct and return a new configuration object instance with specified features enabled.- Since:
- 2.7
-
without
public SerializationConfig without(com.fasterxml.jackson.core.FormatFeature feature)
Fluent factory method that will construct and return a new configuration object instance with specified feature disabled.- Since:
- 2.7
-
withoutFeatures
public SerializationConfig withoutFeatures(com.fasterxml.jackson.core.FormatFeature... features)
Fluent factory method that will construct and return a new configuration object instance with specified features disabled.- Since:
- 2.7
-
withFilters
public SerializationConfig withFilters(FilterProvider filterProvider)
-
withPropertyInclusion
@Deprecated public SerializationConfig withPropertyInclusion(com.fasterxml.jackson.annotation.JsonInclude.Value incl)
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
public SerializationConfig withDefaultPrettyPrinter(com.fasterxml.jackson.core.PrettyPrinter pp)
- Since:
- 2.6
-
constructDefaultPrettyPrinter
public com.fasterxml.jackson.core.PrettyPrinter constructDefaultPrettyPrinter()
-
initialize
public void initialize(com.fasterxml.jackson.core.JsonGenerator g)
Method called byObjectMapperandObjectWriterto modify thoseJsonGenerator.Featuresettings that have been configured via this config instance.- Since:
- 2.5
-
getSerializationInclusion
@Deprecated public com.fasterxml.jackson.annotation.JsonInclude.Include 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
public final boolean isEnabled(SerializationFeature f)
-
isEnabled
public final boolean isEnabled(com.fasterxml.jackson.core.JsonGenerator.Feature f, com.fasterxml.jackson.core.JsonFactory factory)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()
-
getFilterProvider
public FilterProvider 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
public com.fasterxml.jackson.core.PrettyPrinter 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
-
introspect
public <T extends BeanDescription> T introspect(JavaType type)
Method that will introspect full bean properties for the purpose of building a bean serializer
-
-