com.fasterxml.jackson.databind.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,
com.fasterxml.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,
com..
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 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
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 com.
and/or com. 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 BeanDeserializerModifier | |
| protected SimpleDeserializers | |
| protected final boolean | _hasExplicitName
Flag that indicates whether module was given an explicit name or not. |
| 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 BeanSerializerModifier | |
| 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 AtomicInteger | |
| 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 | |
| public | |
| public | SimpleModule(String name, Version version, Map<Class<?>, JsonDeserializer<?>> deserializers, List<JsonSerializer<?>> serializers)
|
| 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, JsonDeserializer<? 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, JsonSerializer<T> ser)
Note This method registers "default" (de)serializers only. |
| public SimpleModule | addSerializer(JsonSerializer<?> ser)
Method for adding serializer to handle type that the serializer claims to handle
(see |
| public <T> SimpleModule | addSerializer(Class<? extends T> type, JsonSerializer<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 com. |
| public Object | getTypeId()
Overrides com. null if (but only if!) this class is directly instantiated;
but class name (default impl) for sub-classes.
|
| 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 void | |
| public SimpleModule | |
| public void | |
| public void | |
| public void | |
| public SimpleModule | setMixInAnnotation(Class<?> targetType, Class<?> mixinClass)
Method for specifying that annotations define by |
| protected SimpleModule | |
| public SimpleModule | |
| public void | |
| public void | setupModule(Module.
Implements abstract com. |
| public void | setValueInstantiators(SimpleValueInstantiators svi)
Resets all currently configured value instantiators |
| public Version | version()
Implements abstract com. Implements com. |
| _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) | |
| _deserializerModifier | back to summary |
|---|---|
protected BeanDeserializerModifier _deserializerModifier
| |
| _deserializers | back to summary |
|---|---|
| protected SimpleDeserializers _deserializers | |
| _hasExplicitName | back to summary |
|---|---|
| protected final boolean _hasExplicitName Flag that indicates whether module was given an explicit name
or not. Distinction is used to determine whether method
| |
| _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 BeanSerializerModifier _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 | |
| MODULE_ID_SEQ | back to summary |
|---|---|
| private static final AtomicInteger MODULE_ID_SEQ | |
| 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, Map<Class<?>, JsonDeserializer<?>> deserializers)
| |
| SimpleModule | back to summary |
|---|---|
public SimpleModule(String name, Version version, List<JsonSerializer<?>> serializers)
| |
| SimpleModule | back to summary |
|---|---|
public SimpleModule(String name, Version version, Map<Class<?>, JsonDeserializer<?>> deserializers, List<JsonSerializer<?>> serializers)
| |
| _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, JsonDeserializer<? 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, JsonSerializer<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(JsonSerializer<?> 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, JsonSerializer<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 com. Doc from com. 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.
| |
| getTypeId | back to summary |
|---|---|
| public Object getTypeId() Overrides com. 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 void setAbstractTypes(SimpleAbstractTypeResolver atr) Resets currently configured abstract type mappings | |
| setDeserializerModifier | back to summary |
|---|---|
public SimpleModule setDeserializerModifier(BeanDeserializerModifier mod)
| |
| setDeserializers | back to summary |
|---|---|
| public void setDeserializers(SimpleDeserializers d) Resets all currently configured deserializers. | |
| setKeyDeserializers | back to summary |
|---|---|
| public void setKeyDeserializers(SimpleKeyDeserializers kd) Resets all currently configured key deserializers. | |
| setKeySerializers | back to summary |
|---|---|
| public void 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(BeanSerializerModifier mod)
| |
| setSerializers | back to summary |
|---|---|
| public void setSerializers(SimpleSerializers s) Resets all currently configured serializers. | |
| setupModule | back to summary |
|---|---|
| public void setupModule(Module. Implements abstract com. 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 void setValueInstantiators(SimpleValueInstantiators svi) Resets all currently configured value instantiators | |
| version | back to summary |
|---|---|
| public Version version() Implements abstract com. Implements com. Doc from com. Method that returns version of this module. Can be used by Jackson for informational purposes.
| |