public class SerializationConfig extends MapperConfig<T>
ObjectMapper
, which makes
a copy that is passed during serialization process to
SerializerProvider
and SerializerFactory
.
Note: although configuration settings can be changed at any time (for factories and instances), they are not guaranteed to have effect if called after constructing relevant mapper or serializer instance. This because some objects may be configured, constructed and cached first time they are needed.
As of version 1.9, the goal is to make this class eventually immutable. Because of this, existing methods that allow changing state of this instance are deprecated in favor of methods that create new instances with different configuration ("fluent factories")
限定符和类型 | 类和说明 |
---|---|
static class |
SerializationConfig.Feature
Enumeration that defines togglable features that guide
the serialization feature.
|
MapperConfig.Base, MapperConfig.ConfigFeature
限定符和类型 | 字段和说明 |
---|---|
protected int |
_featureFlags
Note: moved to base class in 1.9; was stored by sub-class earlier
|
protected FilterProvider |
_filterProvider
Object used for resolving filter ids to filter instances.
|
protected JsonSerialize.Inclusion |
_serializationInclusion
Which Bean/Map properties are to be included in serialization?
|
protected Class<?> |
_serializationView
View to use for filtering out properties to serialize.
|
_base, _mixInAnnotations, _mixInAnnotationsShared, _subtypeResolver, DEFAULT_DATE_FORMAT
限定符 | 构造器和说明 |
---|---|
|
SerializationConfig(ClassIntrospector<? extends BeanDescription> intr,
AnnotationIntrospector annIntr,
VisibilityChecker<?> vc,
SubtypeResolver subtypeResolver,
PropertyNamingStrategy propertyNamingStrategy,
TypeFactory typeFactory,
HandlerInstantiator handlerInstantiator)
Constructor used by ObjectMapper to create default configuration object instance.
|
protected |
SerializationConfig(SerializationConfig src) |
protected |
SerializationConfig(SerializationConfig src,
Class<?> view) |
protected |
SerializationConfig(SerializationConfig src,
FilterProvider filters) |
protected |
SerializationConfig(SerializationConfig src,
HashMap<ClassKey,Class<?>> mixins,
SubtypeResolver str)
Constructor used to make a private copy of specific mix-in definitions.
|
protected |
SerializationConfig(SerializationConfig src,
int features) |
protected |
SerializationConfig(SerializationConfig src,
JsonSerialize.Inclusion incl) |
protected |
SerializationConfig(SerializationConfig src,
MapperConfig.Base base) |
限定符和类型 | 方法和说明 |
---|---|
boolean |
canOverrideAccessModifiers()
Accessor for determining whether it is ok to try to force override of access
modifiers to be able to get or set values of non-public Methods, Fields;
to invoke non-public Constructors, Methods; or to instantiate non-public
Classes.
|
SerializationConfig |
createUnshared(SubtypeResolver subtypeResolver)
Method to use for constructing an instance that is not shared
between multiple operations but only used for a single one
(which may be this instance, if it is immutable; if not, a copy
is constructed with same settings)
|
void |
disable(SerializationConfig.Feature f)
已过时。
Since 1.9, it is preferable to use
without(org.codehaus.jackson.map.SerializationConfig.Feature...) instead;
this method is deprecated as it modifies current instance instead of
creating a new one (as the goal is to make this class immutable) |
void |
enable(SerializationConfig.Feature f)
已过时。
Since 1.9, it is preferable to use
with(org.codehaus.jackson.map.SerializationConfig.Feature...) instead;
this method is deprecated as it modifies current instance instead of
creating a new one (as the goal is to make this class immutable) |
void |
fromAnnotations(Class<?> cls)
已过时。
Since 1.9, it is preferably to explicitly configure
instances; this method also modifies existing instance which is
against immutable design goals of this class.
|
AnnotationIntrospector |
getAnnotationIntrospector()
Method for getting
AnnotationIntrospector configured
to introspect annotation values used for configuration. |
VisibilityChecker<?> |
getDefaultVisibilityChecker()
Accessor for object used for determining whether specific property elements
(method, constructors, fields) can be auto-detected based on
their visibility (access modifiers).
|
FilterProvider |
getFilterProvider()
Method for getting provider used for locating filters given
id (which is usually provided with filter annotations).
|
JsonSerialize.Inclusion |
getSerializationInclusion() |
Class<?> |
getSerializationView()
Method for checking which serialization view is being used,
if any; null if none.
|
<T extends BeanDescription> |
introspect(JavaType type)
Method that will introspect full bean properties for the purpose
of building a bean serializer
|
<T extends BeanDescription> |
introspectClassAnnotations(JavaType type)
Accessor for getting bean description that only contains class
annotations: useful if no getter/setter/creator information is needed.
|
<T extends BeanDescription> |
introspectDirectClassAnnotations(JavaType type)
Accessor for getting bean description that only contains immediate class
annotations: ones from the class, and its direct mix-in, if any, but
not from super types.
|
boolean |
isAnnotationProcessingEnabled()
Method for determining whether annotation processing is enabled or not
(default settings are typically that it is enabled; must explicitly disable).
|
boolean |
isEnabled(MapperConfig.ConfigFeature f)
Method for checking whether given feature is enabled or not
|
boolean |
isEnabled(SerializationConfig.Feature f)
|
JsonSerializer<Object> |
serializerInstance(Annotated annotated,
Class<? extends JsonSerializer<?>> serClass) |
void |
set(SerializationConfig.Feature f,
boolean state)
已过时。
Since 1.9, it is preferable to use
without(org.codehaus.jackson.map.SerializationConfig.Feature...) and with(org.codehaus.jackson.map.SerializationConfig.Feature...) instead;
this method is deprecated as it modifies current instance instead of
creating a new one (as the goal is to make this class immutable) |
void |
setDateFormat(DateFormat df)
已过时。
Since 1.8, use
withDateFormat(java.text.DateFormat) instead. |
void |
setSerializationInclusion(JsonSerialize.Inclusion props)
已过时。
since 1.9 should either use
withSerializationInclusion(org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion)
to construct new instance, or configure through ObjectMapper |
void |
setSerializationView(Class<?> view)
已过时。
Since 1.8, use
withView(java.lang.Class<?>) instead |
boolean |
shouldSortPropertiesAlphabetically()
Accessor for checking whether default settings for property handling
indicate that properties should be alphabetically ordered or not.
|
String |
toString() |
SerializationConfig |
with(SerializationConfig.Feature... features)
Fluent factory method that will construct and return a new configuration
object instance with specified features enabled.
|
SerializationConfig |
withAnnotationIntrospector(AnnotationIntrospector ai)
Method for constructing and returning a new instance with different
AnnotationIntrospector to use (replacing old one). |
SerializationConfig |
withAppendedAnnotationIntrospector(AnnotationIntrospector ai)
Method for constructing and returning a new instance with additional
AnnotationIntrospector appended (as the lowest priority one) |
SerializationConfig |
withClassIntrospector(ClassIntrospector<? extends BeanDescription> ci)
Method for constructing and returning a new instance with different
ClassIntrospector
to use. |
SerializationConfig |
withDateFormat(DateFormat df)
In addition to constructing instance with specified date format,
will enable or disable
Feature.WRITE_DATES_AS_TIMESTAMPS
(enable if format set as null; disable if non-null) |
SerializationConfig |
withFilters(FilterProvider filterProvider) |
SerializationConfig |
withHandlerInstantiator(HandlerInstantiator hi)
Method for constructing and returning a new instance with different
HandlerInstantiator
to use. |
SerializationConfig |
withInsertedAnnotationIntrospector(AnnotationIntrospector ai)
Method for constructing and returning a new instance with additional
AnnotationIntrospector inserted (as the highest priority one) |
SerializationConfig |
without(SerializationConfig.Feature... features)
Fluent factory method that will construct and return a new configuration
object instance with specified features disabled.
|
SerializationConfig |
withPropertyNamingStrategy(PropertyNamingStrategy pns)
Method for constructing and returning a new instance with different
PropertyNamingStrategy
to use. |
SerializationConfig |
withSerializationInclusion(JsonSerialize.Inclusion incl) |
SerializationConfig |
withSubtypeResolver(SubtypeResolver str)
Method for constructing and returning a new instance with different
SubtypeResolver
to use. |
SerializationConfig |
withTypeFactory(TypeFactory tf)
Method for constructing and returning a new instance with different
TypeFactory
to use. |
SerializationConfig |
withTypeResolverBuilder(TypeResolverBuilder<?> trb)
Method for constructing and returning a new instance with different
TypeResolverBuilder
to use. |
SerializationConfig |
withView(Class<?> view) |
SerializationConfig |
withVisibility(JsonMethod forMethod,
JsonAutoDetect.Visibility visibility)
Method for constructing and returning a new instance with different
minimal visibility level for specified property type
NOTE: make sure to register new instance with
ObjectMapper
if directly calling this method. |
SerializationConfig |
withVisibilityChecker(VisibilityChecker<?> vc)
Method for constructing and returning a new instance with different
VisibilityChecker
to use. |
addMixInAnnotations, appendAnnotationIntrospector, constructSpecializedType, constructType, constructType, findMixInClassFor, getClassIntrospector, getDateFormat, getDefaultTyper, getHandlerInstantiator, getPropertyNamingStrategy, getSubtypeResolver, getTypeFactory, insertAnnotationIntrospector, introspectClassAnnotations, introspectDirectClassAnnotations, mixInCount, setAnnotationIntrospector, setMixInAnnotations, typeIdResolverInstance, typeResolverBuilderInstance
protected JsonSerialize.Inclusion _serializationInclusion
Defaults to null for backwards compatibility; if left as null,
will check
deprecated SerializationConfig.Feature.WRITE_NULL_PROPERTIES
to choose between JsonSerialize.Inclusion.ALWAYS
and JsonSerialize.Inclusion.NON_NULL
.
protected Class<?> _serializationView
Object.class
is defined), meaning that all properties are to be included.protected FilterProvider _filterProvider
protected int _featureFlags
Note: moved to base class in 1.9; was stored by sub-class earlier
public SerializationConfig(ClassIntrospector<? extends BeanDescription> intr, AnnotationIntrospector annIntr, VisibilityChecker<?> vc, SubtypeResolver subtypeResolver, PropertyNamingStrategy propertyNamingStrategy, TypeFactory typeFactory, HandlerInstantiator handlerInstantiator)
protected SerializationConfig(SerializationConfig src)
protected SerializationConfig(SerializationConfig src, HashMap<ClassKey,Class<?>> mixins, SubtypeResolver str)
protected SerializationConfig(SerializationConfig src, MapperConfig.Base base)
protected SerializationConfig(SerializationConfig src, FilterProvider filters)
protected SerializationConfig(SerializationConfig src, Class<?> view)
protected SerializationConfig(SerializationConfig src, JsonSerialize.Inclusion incl)
protected SerializationConfig(SerializationConfig src, int features)
public SerializationConfig withClassIntrospector(ClassIntrospector<? extends BeanDescription> ci)
MapperConfig
ClassIntrospector
to use.
NOTE: make sure to register new instance with ObjectMapper
if directly calling this method.
public SerializationConfig withAnnotationIntrospector(AnnotationIntrospector ai)
MapperConfig
AnnotationIntrospector
to use (replacing old one).
NOTE: make sure to register new instance with ObjectMapper
if directly calling this method.
public SerializationConfig withInsertedAnnotationIntrospector(AnnotationIntrospector ai)
MapperConfig
AnnotationIntrospector
inserted (as the highest priority one)public SerializationConfig withAppendedAnnotationIntrospector(AnnotationIntrospector ai)
MapperConfig
AnnotationIntrospector
appended (as the lowest priority one)public SerializationConfig withVisibilityChecker(VisibilityChecker<?> vc)
MapperConfig
VisibilityChecker
to use.
NOTE: make sure to register new instance with ObjectMapper
if directly calling this method.
public SerializationConfig withVisibility(JsonMethod forMethod, JsonAutoDetect.Visibility visibility)
MapperConfig
NOTE: make sure to register new instance with ObjectMapper
if directly calling this method.
withVisibility
在类中 MapperConfig<SerializationConfig>
public SerializationConfig withTypeResolverBuilder(TypeResolverBuilder<?> trb)
MapperConfig
TypeResolverBuilder
to use.
NOTE: make sure to register new instance with ObjectMapper
if directly calling this method.
public SerializationConfig withSubtypeResolver(SubtypeResolver str)
MapperConfig
SubtypeResolver
to use.
NOTE: make sure to register new instance with ObjectMapper
if directly calling this method.
public SerializationConfig withPropertyNamingStrategy(PropertyNamingStrategy pns)
MapperConfig
PropertyNamingStrategy
to use.
NOTE: make sure to register new instance with ObjectMapper
if directly calling this method.
public SerializationConfig withTypeFactory(TypeFactory tf)
MapperConfig
TypeFactory
to use.
NOTE: make sure to register new instance with ObjectMapper
if directly calling this method.
withTypeFactory
在类中 MapperConfig<SerializationConfig>
public SerializationConfig withDateFormat(DateFormat df)
Feature.WRITE_DATES_AS_TIMESTAMPS
(enable if format set as null; disable if non-null)withDateFormat
在类中 MapperConfig<SerializationConfig>
public SerializationConfig withHandlerInstantiator(HandlerInstantiator hi)
MapperConfig
HandlerInstantiator
to use.
NOTE: make sure to register new instance with ObjectMapper
if directly calling this method.
public SerializationConfig withFilters(FilterProvider filterProvider)
public SerializationConfig withView(Class<?> view)
public SerializationConfig withSerializationInclusion(JsonSerialize.Inclusion incl)
public SerializationConfig with(SerializationConfig.Feature... features)
public SerializationConfig without(SerializationConfig.Feature... features)
@Deprecated public void fromAnnotations(Class<?> cls)
Serialization annotations that are known to have effect are:
fromAnnotations
在类中 MapperConfig<SerializationConfig>
cls
- Class of which class annotations to use
for changing configuration settingspublic SerializationConfig createUnshared(SubtypeResolver subtypeResolver)
MapperConfig
createUnshared
在类中 MapperConfig<SerializationConfig>
public AnnotationIntrospector getAnnotationIntrospector()
MapperConfig
AnnotationIntrospector
configured
to introspect annotation values used for configuration.
Non-final since it is actually overridden by sub-classes (for now?)
public <T extends BeanDescription> T introspectClassAnnotations(JavaType type)
Note: part of MapperConfig
since 1.7
public <T extends BeanDescription> T introspectDirectClassAnnotations(JavaType type)
Note: part of MapperConfig
since 1.7
public boolean isAnnotationProcessingEnabled()
MapperConfig
isAnnotationProcessingEnabled
在类中 MapperConfig<SerializationConfig>
public boolean canOverrideAccessModifiers()
MapperConfig
canOverrideAccessModifiers
在类中 MapperConfig<SerializationConfig>
public boolean shouldSortPropertiesAlphabetically()
MapperConfig
public VisibilityChecker<?> getDefaultVisibilityChecker()
MapperConfig
JsonAutoDetect
annotation)public boolean isEnabled(SerializationConfig.Feature f)
@Deprecated public void enable(SerializationConfig.Feature f)
with(org.codehaus.jackson.map.SerializationConfig.Feature...)
instead;
this method is deprecated as it modifies current instance instead of
creating a new one (as the goal is to make this class immutable)@Deprecated public void disable(SerializationConfig.Feature f)
without(org.codehaus.jackson.map.SerializationConfig.Feature...)
instead;
this method is deprecated as it modifies current instance instead of
creating a new one (as the goal is to make this class immutable)@Deprecated public void set(SerializationConfig.Feature f, boolean state)
without(org.codehaus.jackson.map.SerializationConfig.Feature...)
and with(org.codehaus.jackson.map.SerializationConfig.Feature...)
instead;
this method is deprecated as it modifies current instance instead of
creating a new one (as the goal is to make this class immutable)public Class<?> getSerializationView()
public JsonSerialize.Inclusion getSerializationInclusion()
@Deprecated public void setSerializationInclusion(JsonSerialize.Inclusion props)
withSerializationInclusion(org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion)
to construct new instance, or configure through ObjectMapper
public FilterProvider getFilterProvider()
ObjectWriter
(or if serialization directly called from ObjectMapper
)public <T extends BeanDescription> T introspect(JavaType type)
public JsonSerializer<Object> serializerInstance(Annotated annotated, Class<? extends JsonSerializer<?>> serClass)
@Deprecated public final void setDateFormat(DateFormat df)
withDateFormat(java.text.DateFormat)
instead.SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS
to false (if null format set), or true (if non-null format)setDateFormat
在类中 MapperConfig<SerializationConfig>
df
- Date format to use, if not null; if null, the default format
will be used@Deprecated public void setSerializationView(Class<?> view)
withView(java.lang.Class<?>)
insteadpublic boolean isEnabled(MapperConfig.ConfigFeature f)
MapperConfig
isEnabled
在类中 MapperConfig<T extends org.codehaus.jackson.map.MapperConfig.Impl<CFG,T>>