Class SimpleSerializers
java.lang.Object
edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.ser.Serializers.Base
edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.module.SimpleSerializers
- All Implemented Interfaces:
Serializers
,Serializable
Simple implementation
Serializers
which allows registration of
serializers based on raw (type erased class).
It can work well for basic bean and scalar type serializers, but is not
a good fit for handling generic types (like Map
s and Collection
s).
Type registrations are assumed to be general; meaning that registration of serializer
for a super type will also be used for handling subtypes, unless an exact match
is found first. As an example, handler for CharSequence
would also be used
serializing StringBuilder
instances, unless a direct mapping was found.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.ser.Serializers
Serializers.Base
-
Field Summary
Modifier and TypeFieldDescriptionprotected HashMap<ClassKey,
JsonSerializer<?>> Class-based mappings that are used both for exact and sub-class matches.protected boolean
Flag to help find "generic" enum serializer, if one has been registered.protected HashMap<ClassKey,
JsonSerializer<?>> Interface-based matches. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
_addSerializer
(Class<?> cls, JsonSerializer<?> ser) protected JsonSerializer<?>
_findInterfaceMapping
(Class<?> cls, ClassKey key) void
addSerializer
(JsonSerializer<?> ser) Method for adding given serializer for type thatJsonSerializer.handledType()
specifies (which MUST return a non-null class; and can NOT beObject
, as a sanity check).<T> void
addSerializer
(Class<? extends T> type, JsonSerializer<T> ser) void
addSerializers
(List<JsonSerializer<?>> sers) findArraySerializer
(SerializationConfig config, ArrayType type, BeanDescription beanDesc, TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer) Method called by serialization framework first time a serializer is needed for specified array type.findCollectionLikeSerializer
(SerializationConfig config, CollectionLikeType type, BeanDescription beanDesc, TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer) Method called by serialization framework first time a serializer is needed for specified "Collection-like" type (type that acts likeCollection
, but does not implement it).findCollectionSerializer
(SerializationConfig config, CollectionType type, BeanDescription beanDesc, TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer) Method called by serialization framework first time a serializer is needed for specifiedCollection
type.findMapLikeSerializer
(SerializationConfig config, MapLikeType type, BeanDescription beanDesc, JsonSerializer<Object> keySerializer, TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer) Method called by serialization framework first time a serializer is needed for specified "Map-like" type (type that acts likeMap
, but does not implement it).findMapSerializer
(SerializationConfig config, MapType type, BeanDescription beanDesc, JsonSerializer<Object> keySerializer, TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer) Method called by serialization framework first time a serializer is needed for specifiedMap
type.findSerializer
(SerializationConfig config, JavaType type, BeanDescription beanDesc) Method called by serialization framework first time a serializer is needed for specified type, which is not of a container or reference type (for which other methods are called).Methods inherited from class edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.ser.Serializers.Base
findReferenceSerializer
-
Field Details
-
_classMappings
Class-based mappings that are used both for exact and sub-class matches. -
_interfaceMappings
Interface-based matches. -
_hasEnumSerializer
protected boolean _hasEnumSerializerFlag to help find "generic" enum serializer, if one has been registered.- Since:
- 2.3
-
-
Constructor Details
-
SimpleSerializers
public SimpleSerializers() -
SimpleSerializers
- Since:
- 2.1
-
-
Method Details
-
addSerializer
Method for adding given serializer for type thatJsonSerializer.handledType()
specifies (which MUST return a non-null class; and can NOT beObject
, as a sanity check). For serializers that do not declare handled type, use the variant that takes two arguments.- Parameters:
ser
-
-
addSerializer
-
addSerializers
- Since:
- 2.1
-
findSerializer
public JsonSerializer<?> findSerializer(SerializationConfig config, JavaType type, BeanDescription beanDesc) Description copied from interface:Serializers
Method called by serialization framework first time a serializer is needed for specified type, which is not of a container or reference type (for which other methods are called).- Specified by:
findSerializer
in interfaceSerializers
- Overrides:
findSerializer
in classSerializers.Base
- Parameters:
config
- Serialization configuration in usetype
- Fully resolved type of instances to serializebeanDesc
- Additional information about type- Returns:
- Configured serializer to use for the type; or null if implementation does not recognize or support type
-
findArraySerializer
public JsonSerializer<?> findArraySerializer(SerializationConfig config, ArrayType type, BeanDescription beanDesc, TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer) Description copied from interface:Serializers
Method called by serialization framework first time a serializer is needed for specified array type. Implementation should return a serializer instance if it supports specified type; or null if it does not.- Specified by:
findArraySerializer
in interfaceSerializers
- Overrides:
findArraySerializer
in classSerializers.Base
-
findCollectionSerializer
public JsonSerializer<?> findCollectionSerializer(SerializationConfig config, CollectionType type, BeanDescription beanDesc, TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer) Description copied from interface:Serializers
Method called by serialization framework first time a serializer is needed for specifiedCollection
type. Implementation should return a serializer instance if it supports specified type; or null if it does not.- Specified by:
findCollectionSerializer
in interfaceSerializers
- Overrides:
findCollectionSerializer
in classSerializers.Base
-
findCollectionLikeSerializer
public JsonSerializer<?> findCollectionLikeSerializer(SerializationConfig config, CollectionLikeType type, BeanDescription beanDesc, TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer) Description copied from interface:Serializers
Method called by serialization framework first time a serializer is needed for specified "Collection-like" type (type that acts likeCollection
, but does not implement it). Implementation should return a serializer instance if it supports specified type; or null if it does not.- Specified by:
findCollectionLikeSerializer
in interfaceSerializers
- Overrides:
findCollectionLikeSerializer
in classSerializers.Base
-
findMapSerializer
public JsonSerializer<?> findMapSerializer(SerializationConfig config, MapType type, BeanDescription beanDesc, JsonSerializer<Object> keySerializer, TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer) Description copied from interface:Serializers
Method called by serialization framework first time a serializer is needed for specifiedMap
type. Implementation should return a serializer instance if it supports specified type; or null if it does not.- Specified by:
findMapSerializer
in interfaceSerializers
- Overrides:
findMapSerializer
in classSerializers.Base
-
findMapLikeSerializer
public JsonSerializer<?> findMapLikeSerializer(SerializationConfig config, MapLikeType type, BeanDescription beanDesc, JsonSerializer<Object> keySerializer, TypeSerializer elementTypeSerializer, JsonSerializer<Object> elementValueSerializer) Description copied from interface:Serializers
Method called by serialization framework first time a serializer is needed for specified "Map-like" type (type that acts likeMap
, but does not implement it). Implementation should return a serializer instance if it supports specified type; or null if it does not.- Specified by:
findMapLikeSerializer
in interfaceSerializers
- Overrides:
findMapLikeSerializer
in classSerializers.Base
-
_findInterfaceMapping
-
_addSerializer
-