Class SimpleModule
- All Implemented Interfaces:
Versioned,Serializable
Module implementation that allows registration
of serializers and deserializers, bean serializer
and deserializer modifiers, registration of subtypes and mix-ins
as well as some other commonly
needed aspects (addition of custom AbstractTypeResolvers,
ValueInstantiators).
NOTE: although it is not expected that sub-types should need to
override setupModule(SetupContext) method, if they choose
to do so they MUST call super.setupModule(context);
to ensure that registration works as expected.
WARNING: when registering JsonSerializers and JsonDeserializers,
only type erased Class is compared: this means that usually you should
NOT use this implementation for registering structured types such as
Collections or Maps: this because parametric
type information will not be considered and you may end up having "wrong" handler
for your type.
What you need to do, instead, is to implement Deserializers
and/or Serializers callbacks to match full type
signatures (with JavaType).
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.Module
Module.SetupContext -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected SimpleAbstractTypeResolverLazily-constructed resolver used for storing mappings from abstract classes to more specific implementing classes (which may be abstract or concrete)protected BeanDeserializerModifierprotected SimpleDeserializersprotected final booleanFlag that indicates whether module was given an explicit name or not.protected SimpleKeyDeserializersprotected SimpleSerializersLazily-constructed map that contains mix-in definitions, indexed by target class, value being mix-in to apply.protected final Stringprotected PropertyNamingStrategyprotected BeanSerializerModifierprotected SimpleSerializersprotected LinkedHashSet<NamedType>Set of subtypes to register, if any.protected SimpleValueInstantiatorsLazily-constructed resolver used for storing mappings from abstract classes to more specific implementing classes (which may be abstract or concrete)protected final Version -
Constructor Summary
ConstructorsConstructorDescriptionConstructors that should only be used for non-reusable convenience modules used by app code: "real" modules should use actual name and version number information.SimpleModule(Version version) Convenience constructor that will use specified Version, including name fromVersion.getArtifactId().SimpleModule(String name) Convenience constructor that will default version toVersion.unknownVersion().SimpleModule(String name, Version version) Constructor to use for actual reusable modules.SimpleModule(String name, Version version, List<JsonSerializer<?>> serializers) SimpleModule(String name, Version version, Map<Class<?>, JsonDeserializer<?>> deserializers) SimpleModule(String name, Version version, Map<Class<?>, JsonDeserializer<?>> deserializers, List<JsonSerializer<?>> serializers) -
Method Summary
Modifier and TypeMethodDescriptionprotected void_checkNotNull(Object thingy, String type) <T> SimpleModuleaddAbstractTypeMapping(Class<T> superType, Class<? extends T> subType) Lazily-constructed resolver used for storing mappings from abstract classes to more specific implementing classes (which may be abstract or concrete)<T> SimpleModuleaddDeserializer(Class<T> type, JsonDeserializer<? extends T> deser) Method for adding deserializer to handle specified type.addKeyDeserializer(Class<?> type, KeyDeserializer deser) <T> SimpleModuleaddKeySerializer(Class<? extends T> type, JsonSerializer<T> ser) addSerializer(JsonSerializer<?> ser) Method for adding serializer to handle type that the serializer claims to handle (seeJsonSerializer.handledType()).<T> SimpleModuleaddSerializer(Class<? extends T> type, JsonSerializer<T> ser) Method for adding serializer to handle values of specific type.addValueInstantiator(Class<?> beanType, ValueInstantiator inst) Method for registeringValueInstantiatorto use when deserializing instances of typebeanType.Method that returns a display that can be used by Jackson for informational purposes, as well as in associating extensions with module that provides them.Since instances are likely to be custom, implementation returnsnullif (but only if!) this class is directly instantiated; but class name (default impl) for sub-classes.registerSubtypes(NamedType... subtypes) Method for adding set of subtypes (along with type name to use) to be registered withObjectMapperthis is an alternative to using annotations in super type to indicate subtypes.registerSubtypes(Class<?>... subtypes) Method for adding set of subtypes to be registered withObjectMapperthis is an alternative to using annotations in super type to indicate subtypes.registerSubtypes(Collection<Class<?>> subtypes) Method for adding set of subtypes (along with type name to use) to be registered withObjectMapperthis is an alternative to using annotations in super type to indicate subtypes.voidResets currently configured abstract type mappingsvoidResets all currently configured deserializers.voidResets all currently configured key deserializers.voidResets all currently configured key serializers.setMixInAnnotation(Class<?> targetType, Class<?> mixinClass) Method for specifying that annotations define bymixinClassshould be "mixed in" with annotations thattargetTypehas (as if they were directly included on it!).protected SimpleModulevoidResets all currently configured serializers.voidsetupModule(Module.SetupContext context) Standard implementation handles registration of all configured customizations: it is important that sub-classes call this implementation (usually before additional custom logic) if they choose to override it; otherwise customizations will not be registered.voidResets all currently configured value instantiatorsversion()Method that returns version of this module.Methods inherited from class edu.internet2.middleware.grouperClientExt.com.fasterxml.jackson.databind.Module
getDependencies
-
Field Details
-
_name
-
_version
-
_hasExplicitName
protected final boolean _hasExplicitNameFlag that indicates whether module was given an explicit name or not. Distinction is used to determine whether methodgetTypeId()should return name (yes, if explicit) ornull(if no explicit name was passed).- Since:
- 2.13
-
_serializers
-
_deserializers
-
_keySerializers
-
_keyDeserializers
-
_abstractTypes
Lazily-constructed resolver used for storing mappings from abstract classes to more specific implementing classes (which may be abstract or concrete) -
_valueInstantiators
Lazily-constructed resolver used for storing mappings from abstract classes to more specific implementing classes (which may be abstract or concrete) -
_deserializerModifier
- Since:
- 2.2
-
_serializerModifier
- Since:
- 2.2
-
_mixins
Lazily-constructed map that contains mix-in definitions, indexed by target class, value being mix-in to apply. -
_subtypes
Set of subtypes to register, if any. -
_namingStrategy
- Since:
- 2.3
-
-
Constructor Details
-
SimpleModule
public SimpleModule()Constructors that should only be used for non-reusable convenience modules used by app code: "real" modules should use actual name and version number information. -
SimpleModule
Convenience constructor that will default version toVersion.unknownVersion(). -
SimpleModule
Convenience constructor that will use specified Version, including name fromVersion.getArtifactId(). -
SimpleModule
Constructor to use for actual reusable modules. ObjectMapper may use name as identifier to notice attempts for multiple registrations of the same module (although it does not have to).- Parameters:
name- Unique name of the moduleversion- Version of the module
-
SimpleModule
- Since:
- 2.1
-
SimpleModule
- Since:
- 2.1
-
SimpleModule
public SimpleModule(String name, Version version, Map<Class<?>, JsonDeserializer<?>> deserializers, List<JsonSerializer<?>> serializers) - Since:
- 2.1
-
-
Method Details
-
getTypeId
Since instances are likely to be custom, implementation returnsnullif (but only if!) this class is directly instantiated; but class name (default impl) for sub-classes. -
setSerializers
Resets all currently configured serializers. -
setDeserializers
Resets all currently configured deserializers. -
setKeySerializers
Resets all currently configured key serializers. -
setKeyDeserializers
Resets all currently configured key deserializers. -
setAbstractTypes
Resets currently configured abstract type mappings -
setValueInstantiators
Resets all currently configured value instantiators -
setDeserializerModifier
- Since:
- 2.2
-
setSerializerModifier
- Since:
- 2.2
-
setNamingStrategy
- Since:
- 2.3
-
addSerializer
Method for adding serializer to handle type that the serializer claims to handle (seeJsonSerializer.handledType()).WARNING! Type matching only uses type-erased
Classand should NOT be used when registering serializers for generic types likeCollectionandMap. -
addSerializer
Method for adding serializer to handle values of specific type.WARNING! Type matching only uses type-erased
Classand should NOT be used when registering serializers for generic types likeCollectionandMap. -
addKeySerializer
-
addDeserializer
Method for adding deserializer to handle specified type.WARNING! Type matching only uses type-erased
Classand should NOT be used when registering serializers for generic types likeCollectionandMap. -
addKeyDeserializer
-
addAbstractTypeMapping
Lazily-constructed resolver used for storing mappings from abstract classes to more specific implementing classes (which may be abstract or concrete) -
registerSubtypes
Method for adding set of subtypes to be registered withObjectMapperthis is an alternative to using annotations in super type to indicate subtypes. -
registerSubtypes
Method for adding set of subtypes (along with type name to use) to be registered withObjectMapperthis is an alternative to using annotations in super type to indicate subtypes. -
registerSubtypes
Method for adding set of subtypes (along with type name to use) to be registered withObjectMapperthis is an alternative to using annotations in super type to indicate subtypes.- Since:
- 2.9
-
addValueInstantiator
Method for registeringValueInstantiatorto use when deserializing instances of typebeanType.Instantiator is registered when module is registered for
ObjectMapper. -
setMixInAnnotation
Method for specifying that annotations define bymixinClassshould be "mixed in" with annotations thattargetTypehas (as if they were directly included on it!).Mix-in annotations are registered when module is registered for
ObjectMapper. -
getModuleName
Description copied from class:ModuleMethod that returns a display that can be used by Jackson for informational purposes, as well as in associating extensions with module that provides them.- Specified by:
getModuleNamein classModule
-
setupModule
Standard implementation handles registration of all configured customizations: it is important that sub-classes call this implementation (usually before additional custom logic) if they choose to override it; otherwise customizations will not be registered.- Specified by:
setupModulein classModule
-
version
Description copied from class:ModuleMethod that returns version of this module. Can be used by Jackson for informational purposes. -
_checkNotNull
- Since:
- 2.9
-