JacksonModule 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,
tools.jackson.databind.deser.ValueInstantiator s).Note
that [de]serializers are registered as "default" [de]serializers.
As a result, they will have lower priority than the ones indicated through annotations on
both Class and property-associated annotations -- for example,
tools..
In cases where both module-based [de]serializers and annotation-based [de]serializers are registered,
the [de]serializer specified by the annotation will take precedence.
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 ValueSerializers and ValueDeserializers,
only type erased Class is compared: this means that usually you should
NOT use this implementation for registering structured types such as
java.s or java.s: 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 tools.
and/or tools. callbacks to match full type
signatures (with JavaType).
| Modifier and Type | Field and Description |
|---|---|
| protected SimpleAbstractTypeResolver | _abstractTypes
Lazily-constructed resolver used for storing mappings from abstract classes to more specific implementing classes (which may be abstract or concrete) |
| protected ValueSerializer | |
| protected ValueSerializer | |
| protected ValueDeserializerModifier | |
| protected SimpleDeserializers | |
| protected final Object | _id
Unique id generated to avoid instances from ever matching so all registrations succeed. |
| protected SimpleKeyDeserializers | |
| protected SimpleSerializers | |
| protected HashMap | _mixins
Lazily-constructed map that contains mix-in definitions, indexed by target class, value being mix-in to apply. |
| protected final String | |
| protected PropertyNamingStrategy | |
| protected ValueSerializerModifier | |
| protected SimpleSerializers | |
| protected LinkedHashSet | _subtypes
Set of subtypes to register, if any. |
| protected SimpleValueInstantiators | _valueInstantiators
Lazily-constructed resolver used for storing mappings from abstract classes to more specific implementing classes (which may be abstract or concrete) |
| protected final Version | |
| private static final long |
| Access | Constructor and Description |
|---|---|
| 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. |
| public | SimpleModule(String name)
Convenience constructor that will default version to
|
| public | SimpleModule(Version version)
Convenience constructor that will use specified Version,
including name from |
| public | SimpleModule(String
Unique name of the module name, Version Version of the module version)Constructor to use for actual reusable modules. |
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected void | |
| public <T> SimpleModule | addAbstractTypeMapping(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) |
| public <T> SimpleModule | addDeserializer(Class<T> type, ValueDeserializer<? extends T> deser)
Method for adding deserializer to handle specified type. |
| public SimpleModule | addKeyDeserializer(Class<?> type, KeyDeserializer deser)
Note This method registers "default" (de)serializers only. |
| public <T> SimpleModule | addKeySerializer(Class<? extends T> type, ValueSerializer<T> ser)
Note This method registers "default" (de)serializers only. |
| public SimpleModule | addSerializer(ValueSerializer<?> ser)
Method for adding serializer to handle type that the serializer claims to handle
(see |
| public <T> SimpleModule | addSerializer(Class<? extends T> type, ValueSerializer<T> ser)
Method for adding serializer to handle values of specific type. |
| public SimpleModule | addValueInstantiator(Class<?> beanType, ValueInstantiator inst)
Method for registering |
| public String | getModuleName()
Implements abstract tools. 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. |
| public Object | getRegistrationId()
Overrides tools. Since instances are likely to be custom, implementation returns
|
| public SimpleModule | registerSubtypes(Class<?>... subtypes)
Method for adding set of subtypes to be registered with
|
| public SimpleModule | registerSubtypes(NamedType... subtypes)
Method for adding set of subtypes (along with type name to use) to be registered with
|
| public SimpleModule | registerSubtypes(Collection<Class<?>> subtypes)
Method for adding set of subtypes (along with type name to use) to be registered with
|
| public SimpleModule | |
| public SimpleModule | |
| public SimpleModule | |
| public SimpleModule | |
| public SimpleModule | |
| public SimpleModule | |
| public SimpleModule | |
| public SimpleModule | setMixInAnnotation(Class<?> targetType, Class<?> mixinClass)
Method for specifying that annotations define by |
| protected SimpleModule | |
| public SimpleModule | |
| public SimpleModule | |
| public void | setupModule(JacksonModule.
Implements abstract tools. 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. |
| public SimpleModule | setValueInstantiators(SimpleValueInstantiators svi)
Resets all currently configured value instantiators |
| public Version | version()
Implements abstract tools. Implements tools. Method that returns version of this module. |
| _abstractTypes | back to summary |
|---|---|
| protected SimpleAbstractTypeResolver _abstractTypes Lazily-constructed resolver used for storing mappings from abstract classes to more specific implementing classes (which may be abstract or concrete) | |
| _defaultNullKeySerializer | back to summary |
|---|---|
| protected ValueSerializer<?> _defaultNullKeySerializer | |
| _defaultNullValueSerializer | back to summary |
|---|---|
| protected ValueSerializer<?> _defaultNullValueSerializer | |
| _deserializerModifier | back to summary |
|---|---|
| protected ValueDeserializerModifier _deserializerModifier | |
| _deserializers | back to summary |
|---|---|
| protected SimpleDeserializers _deserializers | |
| _id | back to summary |
|---|---|
| protected final Object _id Unique id generated to avoid instances from ever matching so all registrations succeed. Note If serialization of SimpleModule instance needed, should be
| |
| _keyDeserializers | back to summary |
|---|---|
| protected SimpleKeyDeserializers _keyDeserializers | |
| _keySerializers | back to summary |
|---|---|
| protected SimpleSerializers _keySerializers | |
| _mixins | back to summary |
|---|---|
| protected HashMap<Class<?>, Class<?>> _mixins Lazily-constructed map that contains mix-in definitions, indexed by target class, value being mix-in to apply. | |
| _name | back to summary |
|---|---|
| protected final String _name | |
| _namingStrategy | back to summary |
|---|---|
| protected PropertyNamingStrategy _namingStrategy | |
| _serializerModifier | back to summary |
|---|---|
| protected ValueSerializerModifier _serializerModifier | |
| _serializers | back to summary |
|---|---|
| protected SimpleSerializers _serializers | |
| _subtypes | back to summary |
|---|---|
| protected LinkedHashSet<NamedType> _subtypes Set of subtypes to register, if any. | |
| _valueInstantiators | back to summary |
|---|---|
| protected SimpleValueInstantiators _valueInstantiators Lazily-constructed resolver used for storing mappings from abstract classes to more specific implementing classes (which may be abstract or concrete) | |
| _version | back to summary |
|---|---|
| protected final Version _version | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| SimpleModule | back to summary |
|---|---|
| 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 | back to summary |
|---|---|
| public SimpleModule(String name) Convenience constructor that will default version to
| |
| SimpleModule | back to summary |
|---|---|
| public SimpleModule(Version version) Convenience constructor that will use specified Version,
including name from | |
| SimpleModule | back to summary |
|---|---|
| public SimpleModule(String name, Version version) 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). | |
| SimpleModule | back to summary |
|---|---|
| public SimpleModule(String name, Version version, Object registrationId) | |
| _checkNotNull | back to summary |
|---|---|
| protected void _checkNotNull(Object thingy, String type) | |
| addAbstractTypeMapping | back to summary |
|---|---|
| public <T> SimpleModule addAbstractTypeMapping(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) | |
| addDeserializer | back to summary |
|---|---|
| public <T> SimpleModule addDeserializer(Class<T> type, ValueDeserializer<? extends T> deser) Method for adding deserializer to handle specified type. Warning Type matching only uses type-erased Warning "Last one wins" rule is applied. Possible earlier addition of a serializer for a given Class will be replaced. Note This method registers "default" (de)serializers only. See a note on precedence in class JavaDoc. | |
| addKeyDeserializer | back to summary |
|---|---|
| public SimpleModule addKeyDeserializer(Class<?> type, KeyDeserializer deser) Note This method registers "default" (de)serializers only. See a note on precedence in class JavaDoc. | |
| addKeySerializer | back to summary |
|---|---|
| public <T> SimpleModule addKeySerializer(Class<? extends T> type, ValueSerializer<T> ser) Note This method registers "default" (de)serializers only. See a note on precedence in class JavaDoc. | |
| addSerializer | back to summary |
|---|---|
| public SimpleModule addSerializer(ValueSerializer<?> ser) Method for adding serializer to handle type that the serializer claims to handle
(see Warning Type matching only uses type-erased Warning "Last one wins" rule is applied. Possible earlier addition of a serializer for a given Class will be replaced. Note This method registers "default" (de)serializers only. See a note on precedence in class JavaDoc. | |
| addSerializer | back to summary |
|---|---|
| public <T> SimpleModule addSerializer(Class<? extends T> type, ValueSerializer<T> ser) Method for adding serializer to handle values of specific type. Note This method registers "default" (de)serializers only. See a note on precedence in class JavaDoc. Warning Type matching only uses type-erased Warning "Last one wins" rule is applied. Possible earlier addition of a serializer for a given Class will be replaced. Note This method registers "default" (de)serializers only. See a note on precedence in class JavaDoc. | |
| addValueInstantiator | back to summary |
|---|---|
| public SimpleModule addValueInstantiator(Class<?> beanType, ValueInstantiator inst) Method for registering
Instantiator is
registered when module is registered for | |
| getModuleName | back to summary |
|---|---|
| public String getModuleName() Implements abstract tools. Doc from tools. 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.
| |
| getRegistrationId | back to summary |
|---|---|
| public Object getRegistrationId() Overrides tools. Since instances are likely to be custom, implementation returns
| |
| registerSubtypes | back to summary |
|---|---|
| public SimpleModule registerSubtypes(Class<?>... subtypes) Method for adding set of subtypes to be registered with
| |
| registerSubtypes | back to summary |
|---|---|
| public SimpleModule registerSubtypes(NamedType... subtypes) Method for adding set of subtypes (along with type name to use) to be registered with
| |
| registerSubtypes | back to summary |
|---|---|
| public SimpleModule registerSubtypes(Collection<Class<?>> subtypes) Method for adding set of subtypes (along with type name to use) to be registered with
| |
| setAbstractTypes | back to summary |
|---|---|
| public SimpleModule setAbstractTypes(SimpleAbstractTypeResolver atr) Resets currently configured abstract type mappings | |
| setDefaultNullKeySerializer | back to summary |
|---|---|
| public SimpleModule setDefaultNullKeySerializer(ValueSerializer<?> ser) | |
| setDefaultNullValueSerializer | back to summary |
|---|---|
| public SimpleModule setDefaultNullValueSerializer(ValueSerializer<?> ser) | |
| setDeserializerModifier | back to summary |
|---|---|
| public SimpleModule setDeserializerModifier(ValueDeserializerModifier mod) | |
| setDeserializers | back to summary |
|---|---|
| public SimpleModule setDeserializers(SimpleDeserializers d) Resets all currently configured deserializers. | |
| setKeyDeserializers | back to summary |
|---|---|
| public SimpleModule setKeyDeserializers(SimpleKeyDeserializers kd) Resets all currently configured key deserializers. | |
| setKeySerializers | back to summary |
|---|---|
| public SimpleModule setKeySerializers(SimpleSerializers ks) Resets all currently configured key serializers. | |
| setMixInAnnotation | back to summary |
|---|---|
| public SimpleModule setMixInAnnotation(Class<?> targetType, Class<?> mixinClass) Method for specifying that annotations define by
Mix-in annotations are
registered when module is registered for | |
| setNamingStrategy | back to summary |
|---|---|
| protected SimpleModule setNamingStrategy(PropertyNamingStrategy naming) | |
| setSerializerModifier | back to summary |
|---|---|
| public SimpleModule setSerializerModifier(ValueSerializerModifier mod) | |
| setSerializers | back to summary |
|---|---|
| public SimpleModule setSerializers(SimpleSerializers s) Resets all currently configured serializers. | |
| setupModule | back to summary |
|---|---|
| public void setupModule(JacksonModule. Implements abstract tools. 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.
| |
| setValueInstantiators | back to summary |
|---|---|
| public SimpleModule setValueInstantiators(SimpleValueInstantiators svi) Resets all currently configured value instantiators | |
| version | back to summary |
|---|---|
| public Version version() Implements abstract tools. Implements tools. Doc from tools. Method that returns version of this module. Can be used by Jackson for informational purposes.
| |