public abstract class BasicSerializerFactory extends SerializerFactory
Collection
).
Since all the serializers are eagerly instantiated, and there is no additional introspection or customizability of these types, this factory is essentially stateless.
SerializerFactory.Config
Modifier and Type | Field and Description |
---|---|
protected static HashMap<String,JsonSerializer<?>> |
_arraySerializers |
protected static HashMap<String,JsonSerializer<?>> |
_concrete
Since these are all JDK classes, we shouldn't have to worry
about ClassLoader used to load them.
|
protected static HashMap<String,Class<? extends JsonSerializer<?>>> |
_concreteLazy
Actually it may not make much sense to eagerly instantiate all
kinds of serializers: so this Map actually contains class references,
not instances
|
protected OptionalHandlerFactory |
optionalHandlers
Helper object used to deal with serializers for optional JDK types (like ones
omitted from GAE, Android)
|
Modifier | Constructor and Description |
---|---|
protected |
BasicSerializerFactory()
We will provide default constructor to allow sub-classing,
but make it protected so that no non-singleton instances of
the class will be instantiated.
|
Modifier and Type | Method and Description |
---|---|
protected JsonSerializer<?> |
buildArraySerializer(SerializationConfig config,
ArrayType type,
BasicBeanDescription beanDesc,
BeanProperty property,
boolean staticTyping,
TypeSerializer elementTypeSerializer,
JsonSerializer<Object> elementValueSerializer)
Helper method that handles configuration details when constructing serializers for
Object[] (and subtypes, except for String). |
protected JsonSerializer<?> |
buildCollectionLikeSerializer(SerializationConfig config,
CollectionLikeType type,
BasicBeanDescription beanDesc,
BeanProperty property,
boolean staticTyping,
TypeSerializer elementTypeSerializer,
JsonSerializer<Object> elementValueSerializer)
Helper method that handles configuration details when constructing serializers for
Collection and Collection-like types.
|
protected JsonSerializer<?> |
buildCollectionSerializer(SerializationConfig config,
CollectionType type,
BasicBeanDescription beanDesc,
BeanProperty property,
boolean staticTyping,
TypeSerializer elementTypeSerializer,
JsonSerializer<Object> elementValueSerializer)
Helper method that handles configuration details when constructing serializers for
List types that support efficient by-index access |
JsonSerializer<?> |
buildContainerSerializer(SerializationConfig config,
JavaType type,
BasicBeanDescription beanDesc,
BeanProperty property,
boolean staticTyping) |
protected JsonSerializer<?> |
buildEnumMapSerializer(SerializationConfig config,
JavaType type,
BasicBeanDescription beanDesc,
BeanProperty property,
boolean staticTyping,
TypeSerializer elementTypeSerializer,
JsonSerializer<Object> elementValueSerializer)
Helper method that handles configuration details when constructing serializers for
EnumMap types. |
protected JsonSerializer<?> |
buildEnumSetSerializer(SerializationConfig config,
JavaType type,
BasicBeanDescription beanDesc,
BeanProperty property,
boolean staticTyping,
TypeSerializer elementTypeSerializer,
JsonSerializer<Object> elementValueSerializer) |
protected JsonSerializer<?> |
buildIterableSerializer(SerializationConfig config,
JavaType type,
BasicBeanDescription beanDesc,
BeanProperty property,
boolean staticTyping) |
protected JsonSerializer<?> |
buildIteratorSerializer(SerializationConfig config,
JavaType type,
BasicBeanDescription beanDesc,
BeanProperty property,
boolean staticTyping) |
protected JsonSerializer<?> |
buildMapLikeSerializer(SerializationConfig config,
MapLikeType type,
BasicBeanDescription beanDesc,
BeanProperty property,
boolean staticTyping,
JsonSerializer<Object> keySerializer,
TypeSerializer elementTypeSerializer,
JsonSerializer<Object> elementValueSerializer)
Helper method that handles configuration details when constructing serializers for
all "Map-like" types; both ones that implement
Map and
ones that do not (but that have been indicated to behave like Maps). |
protected JsonSerializer<?> |
buildMapSerializer(SerializationConfig config,
MapType type,
BasicBeanDescription beanDesc,
BeanProperty property,
boolean staticTyping,
JsonSerializer<Object> keySerializer,
TypeSerializer elementTypeSerializer,
JsonSerializer<Object> elementValueSerializer)
Helper method that handles configuration details when constructing serializers for
Map types. |
abstract JsonSerializer<Object> |
createSerializer(SerializationConfig config,
JavaType type,
BeanProperty property)
Method called to create (or, for immutable serializers, reuse) a serializer for given type.
|
TypeSerializer |
createTypeSerializer(SerializationConfig config,
JavaType baseType,
BeanProperty property)
Method called to construct a type serializer for values with given declared
base type.
|
protected abstract Iterable<Serializers> |
customSerializers() |
protected static JsonSerializer<Object> |
findContentSerializer(SerializationConfig config,
Annotated a,
BeanProperty property) |
protected static JsonSerializer<Object> |
findKeySerializer(SerializationConfig config,
Annotated a,
BeanProperty property) |
JsonSerializer<?> |
findSerializerByAddonType(SerializationConfig config,
JavaType javaType,
BasicBeanDescription beanDesc,
BeanProperty property,
boolean staticTyping)
Reflection-based serialized find method, which checks if
given class implements one of recognized "add-on" interfaces.
|
JsonSerializer<?> |
findSerializerByLookup(JavaType type,
SerializationConfig config,
BasicBeanDescription beanDesc,
BeanProperty property,
boolean staticTyping)
Method that will use fast lookup (and identity comparison) methods to
see if we know serializer to use for given type.
|
JsonSerializer<?> |
findSerializerByPrimaryType(JavaType type,
SerializationConfig config,
BasicBeanDescription beanDesc,
BeanProperty property,
boolean staticTyping)
Method for checking if we can determine serializer to use based on set of
known primary types, checking for set of known base types (exact matches
having been compared against with
findSerializerByLookup ). |
protected JsonSerializer<Object> |
findSerializerFromAnnotation(SerializationConfig config,
Annotated a,
BeanProperty property)
Helper method called to check if a class or method
has an annotation
(@link org.codehaus.jackson.map.ser.JsonSerialize#using)
that tells the class to use for serialization.
|
JsonSerializer<?> |
getNullSerializer() |
protected boolean |
isIndexedList(Class<?> cls) |
protected static <T extends JavaType> |
modifySecondaryTypesByAnnotation(SerializationConfig config,
Annotated a,
T type) |
protected <T extends JavaType> |
modifyTypeByAnnotation(SerializationConfig config,
Annotated a,
T type)
Helper method used to encapsulate details of annotation-based type
coercion
|
protected boolean |
usesStaticTyping(SerializationConfig config,
BasicBeanDescription beanDesc,
TypeSerializer typeSer,
BeanProperty property)
Helper method to check whether global settings and/or class
annotations for the bean class indicate that static typing
(declared types) should be used for properties.
|
createKeySerializer, createSerializer, createTypeSerializer, getConfig, withAdditionalKeySerializers, withAdditionalSerializers, withConfig, withSerializerModifier
protected static final HashMap<String,JsonSerializer<?>> _concrete
protected static final HashMap<String,Class<? extends JsonSerializer<?>>> _concreteLazy
protected static final HashMap<String,JsonSerializer<?>> _arraySerializers
protected OptionalHandlerFactory optionalHandlers
protected BasicSerializerFactory()
public abstract JsonSerializer<Object> createSerializer(SerializationConfig config, JavaType type, BeanProperty property) throws JsonMappingException
SerializerFactory
createSerializer
in class SerializerFactory
JsonMappingException
public TypeSerializer createTypeSerializer(SerializationConfig config, JavaType baseType, BeanProperty property)
createTypeSerializer
in class SerializerFactory
baseType
- Declared type to use as the base type for type information serializerpublic final JsonSerializer<?> getNullSerializer()
protected abstract Iterable<Serializers> customSerializers()
public final JsonSerializer<?> findSerializerByLookup(JavaType type, SerializationConfig config, BasicBeanDescription beanDesc, BeanProperty property, boolean staticTyping)
public final JsonSerializer<?> findSerializerByPrimaryType(JavaType type, SerializationConfig config, BasicBeanDescription beanDesc, BeanProperty property, boolean staticTyping) throws JsonMappingException
findSerializerByLookup
).
This does not include "secondary" interfaces, but
mostly concrete or abstract base classes.JsonMappingException
public final JsonSerializer<?> findSerializerByAddonType(SerializationConfig config, JavaType javaType, BasicBeanDescription beanDesc, BeanProperty property, boolean staticTyping) throws JsonMappingException
Iterable
, but their main
function is usually something else. The reason forJsonMappingException
protected JsonSerializer<Object> findSerializerFromAnnotation(SerializationConfig config, Annotated a, BeanProperty property) throws JsonMappingException
JsonMappingException
public JsonSerializer<?> buildContainerSerializer(SerializationConfig config, JavaType type, BasicBeanDescription beanDesc, BeanProperty property, boolean staticTyping)
protected JsonSerializer<?> buildCollectionLikeSerializer(SerializationConfig config, CollectionLikeType type, BasicBeanDescription beanDesc, BeanProperty property, boolean staticTyping, TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer)
protected JsonSerializer<?> buildCollectionSerializer(SerializationConfig config, CollectionType type, BasicBeanDescription beanDesc, BeanProperty property, boolean staticTyping, TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer)
List
types that support efficient by-index access
Note: signature changed in 1.8, to take 'staticTyping' argument
protected JsonSerializer<?> buildEnumSetSerializer(SerializationConfig config, JavaType type, BasicBeanDescription beanDesc, BeanProperty property, boolean staticTyping, TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer)
protected boolean isIndexedList(Class<?> cls)
protected JsonSerializer<?> buildMapLikeSerializer(SerializationConfig config, MapLikeType type, BasicBeanDescription beanDesc, BeanProperty property, boolean staticTyping, JsonSerializer<Object> keySerializer, TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer)
Map
and
ones that do not (but that have been indicated to behave like Maps).protected JsonSerializer<?> buildMapSerializer(SerializationConfig config, MapType type, BasicBeanDescription beanDesc, BeanProperty property, boolean staticTyping, JsonSerializer<Object> keySerializer, TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer)
Map
types.
Note: signature changed in 1.8, to take 'staticTyping' argument
protected JsonSerializer<?> buildEnumMapSerializer(SerializationConfig config, JavaType type, BasicBeanDescription beanDesc, BeanProperty property, boolean staticTyping, TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer)
EnumMap
types.
Note: signature changed in 1.8, to take 'staticTyping' argument
protected JsonSerializer<?> buildArraySerializer(SerializationConfig config, ArrayType type, BasicBeanDescription beanDesc, BeanProperty property, boolean staticTyping, TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer)
Object[]
(and subtypes, except for String).protected JsonSerializer<?> buildIteratorSerializer(SerializationConfig config, JavaType type, BasicBeanDescription beanDesc, BeanProperty property, boolean staticTyping)
protected JsonSerializer<?> buildIterableSerializer(SerializationConfig config, JavaType type, BasicBeanDescription beanDesc, BeanProperty property, boolean staticTyping)
protected <T extends JavaType> T modifyTypeByAnnotation(SerializationConfig config, Annotated a, T type)
protected static <T extends JavaType> T modifySecondaryTypesByAnnotation(SerializationConfig config, Annotated a, T type)
protected static JsonSerializer<Object> findKeySerializer(SerializationConfig config, Annotated a, BeanProperty property)
protected static JsonSerializer<Object> findContentSerializer(SerializationConfig config, Annotated a, BeanProperty property)
protected boolean usesStaticTyping(SerializationConfig config, BasicBeanDescription beanDesc, TypeSerializer typeSer, BeanProperty property)