public class BeanSerializerFactory extends BasicSerializerFactory implements java.io.Serializable
Object.getClass() does not count);
as well as for "standard" JDK types. Latter is achieved
by delegating calls to BasicSerializerFactory
to find serializers both for "standard" JDK types (and in some cases,
sub-classes as is the case for collection classes like
Lists and Maps) and bean (value)
classes.
Note about delegating calls to BasicSerializerFactory:
although it would be nicer to use linear delegation
for construction (to essentially dispatch all calls first to the
underlying BasicSerializerFactory; or alternatively after
failing to provide bean-based serializer}, there is a problem:
priority levels for detecting standard types are mixed. That is,
we want to check if a type is a bean after some of "standard" JDK
types, but before the rest.
As a result, "mixed" delegation used, and calls are NOT done using
regular SerializerFactory interface but rather via
direct calls to BasicSerializerFactory.
Finally, since all caching is handled by the serializer provider (not factory) and there is no configurability, this factory is stateless. This means that a global singleton instance can be used.
| Modifier and Type | Field and Description |
|---|---|
static BeanSerializerFactory |
instance
Like
BasicSerializerFactory, this factory is stateless, and
thus a single shared global (== singleton) instance can be used
without thread-safety issues. |
| Modifier and Type | Method and Description |
|---|---|
JsonSerializer<java.lang.Object> |
createSerializer(SerializerProvider prov,
JavaType origType)
Main serializer constructor method.
|
JsonSerializer<java.lang.Object> |
findBeanOrAddOnSerializer(SerializerProvider prov,
JavaType type,
BeanDescription beanDesc,
boolean staticTyping)
Method that will try to construct a
BeanSerializer for
given class if at least one property is found, OR, if not,
one of add-on types. |
JsonSerializer<java.lang.Object> |
findBeanSerializer(SerializerProvider prov,
JavaType type,
BeanDescription beanDesc)
Deprecated.
|
TypeSerializer |
findPropertyContentTypeSerializer(JavaType containerType,
SerializationConfig config,
AnnotatedMember accessor)
Method called to create a type information serializer for values of given
container property
if one is needed.
|
TypeSerializer |
findPropertyTypeSerializer(JavaType baseType,
SerializationConfig config,
AnnotatedMember accessor)
Method called to create a type information serializer for values of given
non-container property
if one is needed.
|
SerializerFactory |
withConfig(SerializerFactoryConfig config)
Method used by module registration functionality, to attach additional
serializer providers into this serializer factory.
|
buildCollectionSerializer, buildEnumSetSerializer, buildIndexedListSerializer, createKeySerializer, createKeySerializer, createTypeSerializer, findReferenceSerializer, getFactoryConfig, withAdditionalKeySerializers, withAdditionalSerializers, withSerializerModifierpublic static final BeanSerializerFactory instance
BasicSerializerFactory, this factory is stateless, and
thus a single shared global (== singleton) instance can be used
without thread-safety issues.public SerializerFactory withConfig(SerializerFactoryConfig config)
withConfig in class BasicSerializerFactorypublic JsonSerializer<java.lang.Object> createSerializer(SerializerProvider prov, JavaType origType) throws JsonMappingException
Iterable.
Note: sub-classes may choose to complete replace implementation, if they want to alter priority of serializer lookups.
createSerializer in class BasicSerializerFactoryprov - Provider that needs to be used to resolve annotation-provided
serializers (but NOT for others)JsonMappingException@Deprecated public JsonSerializer<java.lang.Object> findBeanSerializer(SerializerProvider prov, JavaType type, BeanDescription beanDesc) throws JsonMappingException
JsonMappingExceptionpublic JsonSerializer<java.lang.Object> findBeanOrAddOnSerializer(SerializerProvider prov, JavaType type, BeanDescription beanDesc, boolean staticTyping) throws JsonMappingException
BeanSerializer for
given class if at least one property is found, OR, if not,
one of add-on types.
NOTE: behavior changed a bit
JsonMappingExceptionpublic TypeSerializer findPropertyTypeSerializer(JavaType baseType, SerializationConfig config, AnnotatedMember accessor) throws JsonMappingException
baseType - Declared type to use as the base type for type information serializerJsonMappingExceptionpublic TypeSerializer findPropertyContentTypeSerializer(JavaType containerType, SerializationConfig config, AnnotatedMember accessor) throws JsonMappingException
containerType - Declared type of the container to use as the base type for type information serializerJsonMappingExceptionCopyright © 2010 - 2023 Adobe. All Rights Reserved