public class SimpleModule extends Module implements 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 Module.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).
Module.SetupContext| Modifier and Type | Field and Description | 
|---|---|
| protected SimpleAbstractTypeResolver | _abstractTypesLazily-constructed resolver used for storing mappings from
 abstract classes to more specific implementing classes
 (which may be abstract or concrete) | 
| protected BeanDeserializerModifier | _deserializerModifier | 
| protected SimpleDeserializers | _deserializers | 
| protected SimpleKeyDeserializers | _keyDeserializers | 
| protected SimpleSerializers | _keySerializers | 
| protected HashMap<Class<?>,Class<?>> | _mixinsLazily-constructed map that contains mix-in definitions, indexed
 by target class, value being mix-in to apply. | 
| protected String | _name | 
| protected PropertyNamingStrategy | _namingStrategy | 
| protected BeanSerializerModifier | _serializerModifier | 
| protected SimpleSerializers | _serializers | 
| protected LinkedHashSet<NamedType> | _subtypesSet of subtypes to register, if any. | 
| protected SimpleValueInstantiators | _valueInstantiatorsLazily-constructed resolver used for storing mappings from
 abstract classes to more specific implementing classes
 (which may be abstract or concrete) | 
| protected Version | _version | 
| Constructor and Description | 
|---|
| 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(String name)Convenience constructor that will default version to
  Version.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) | 
| SimpleModule(Version version)Convenience constructor that will use specified Version,
 including name from  Version.getArtifactId() | 
| Modifier and Type | Method and Description | 
|---|---|
| protected void | _checkNotNull(Object thingy,
             String type) | 
| <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) | 
| <T> SimpleModule | addDeserializer(Class<T> type,
               JsonDeserializer<? extends T> deser)Method for adding deserializer to handle specified type. | 
| SimpleModule | addKeyDeserializer(Class<?> type,
                  KeyDeserializer deser) | 
| <T> SimpleModule | addKeySerializer(Class<? extends T> type,
                JsonSerializer<T> ser) | 
| <T> SimpleModule | addSerializer(Class<? extends T> type,
             JsonSerializer<T> ser)Method for adding serializer to handle values of specific type. | 
| SimpleModule | addSerializer(JsonSerializer<?> ser)Method for adding serializer to handle type that the serializer claims to handle
 (see  JsonSerializer.handledType()). | 
| SimpleModule | addValueInstantiator(Class<?> beanType,
                    ValueInstantiator inst)Method for registering  ValueInstantiatorto use when deserializing
 instances of typebeanType. | 
| String | getModuleName()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. | 
| Object | getTypeId()Since instances are likely to be custom, implementation returns
  nullif (but only if!) this class is directly instantiated;
 but class name (default impl) for sub-classes. | 
| SimpleModule | registerSubtypes(Class<?>... subtypes)Method for adding set of subtypes to be registered with
  ObjectMapperthis is an alternative to using annotations in super type to indicate subtypes. | 
| SimpleModule | registerSubtypes(Collection<Class<?>> subtypes)Method for adding set of subtypes (along with type name to use) to be registered with
  ObjectMapperthis is an alternative to using annotations in super type to indicate subtypes. | 
| SimpleModule | registerSubtypes(NamedType... subtypes)Method for adding set of subtypes (along with type name to use) to be registered with
  ObjectMapperthis is an alternative to using annotations in super type to indicate subtypes. | 
| void | setAbstractTypes(SimpleAbstractTypeResolver atr)Resets currently configured abstract type mappings | 
| SimpleModule | setDeserializerModifier(BeanDeserializerModifier mod) | 
| void | setDeserializers(SimpleDeserializers d)Resets all currently configured deserializers. | 
| void | setKeyDeserializers(SimpleKeyDeserializers kd)Resets all currently configured key deserializers. | 
| void | setKeySerializers(SimpleSerializers ks)Resets all currently configured key serializers. | 
| SimpleModule | setMixInAnnotation(Class<?> targetType,
                  Class<?> mixinClass)Method for specifying that annotations define by  mixinClassshould be "mixed in" with annotations thattargetTypehas (as if they were directly included on it!). | 
| protected SimpleModule | setNamingStrategy(PropertyNamingStrategy naming) | 
| SimpleModule | setSerializerModifier(BeanSerializerModifier mod) | 
| void | setSerializers(SimpleSerializers s)Resets all currently configured serializers. | 
| void | setupModule(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. | 
| void | setValueInstantiators(SimpleValueInstantiators svi)Resets all currently configured value instantiators | 
| Version | version()Method that returns version of this module. | 
getDependenciesprotected final String _name
protected final Version _version
protected SimpleSerializers _serializers
protected SimpleDeserializers _deserializers
protected SimpleSerializers _keySerializers
protected SimpleKeyDeserializers _keyDeserializers
protected SimpleAbstractTypeResolver _abstractTypes
protected SimpleValueInstantiators _valueInstantiators
protected BeanDeserializerModifier _deserializerModifier
protected BeanSerializerModifier _serializerModifier
protected HashMap<Class<?>,Class<?>> _mixins
protected LinkedHashSet<NamedType> _subtypes
protected PropertyNamingStrategy _namingStrategy
public SimpleModule()
public SimpleModule(String name)
Version.unknownVersion().public SimpleModule(Version version)
Version.getArtifactId()public SimpleModule(String name, Version version)
name - Unique name of the moduleversion - Version of the modulepublic SimpleModule(String name, Version version, Map<Class<?>,JsonDeserializer<?>> deserializers)
public SimpleModule(String name, Version version, List<JsonSerializer<?>> serializers)
public SimpleModule(String name, Version version, Map<Class<?>,JsonDeserializer<?>> deserializers, List<JsonSerializer<?>> serializers)
public Object getTypeId()
null if (but only if!) this class is directly instantiated;
 but class name (default impl) for sub-classes.public void setSerializers(SimpleSerializers s)
public void setDeserializers(SimpleDeserializers d)
public void setKeySerializers(SimpleSerializers ks)
public void setKeyDeserializers(SimpleKeyDeserializers kd)
public void setAbstractTypes(SimpleAbstractTypeResolver atr)
public void setValueInstantiators(SimpleValueInstantiators svi)
public SimpleModule setDeserializerModifier(BeanDeserializerModifier mod)
public SimpleModule setSerializerModifier(BeanSerializerModifier mod)
protected SimpleModule setNamingStrategy(PropertyNamingStrategy naming)
public SimpleModule addSerializer(JsonSerializer<?> ser)
JsonSerializer.handledType()).
 WARNING! Type matching only uses type-erased Class and should NOT
 be used when registering serializers for generic types like
 Collection and Map.
public <T> SimpleModule addSerializer(Class<? extends T> type, JsonSerializer<T> ser)
 WARNING! Type matching only uses type-erased Class and should NOT
 be used when registering serializers for generic types like
 Collection and Map.
public <T> SimpleModule addKeySerializer(Class<? extends T> type, JsonSerializer<T> ser)
public <T> SimpleModule addDeserializer(Class<T> type, JsonDeserializer<? extends T> deser)
 WARNING! Type matching only uses type-erased Class and should NOT
 be used when registering serializers for generic types like
 Collection and Map.
public SimpleModule addKeyDeserializer(Class<?> type, KeyDeserializer deser)
public <T> SimpleModule addAbstractTypeMapping(Class<T> superType, Class<? extends T> subType)
public SimpleModule registerSubtypes(Class<?>... subtypes)
ObjectMapper
 this is an alternative to using annotations in super type to indicate subtypes.public SimpleModule registerSubtypes(NamedType... subtypes)
ObjectMapper
 this is an alternative to using annotations in super type to indicate subtypes.public SimpleModule registerSubtypes(Collection<Class<?>> subtypes)
ObjectMapper
 this is an alternative to using annotations in super type to indicate subtypes.public SimpleModule addValueInstantiator(Class<?> beanType, ValueInstantiator inst)
ValueInstantiator to use when deserializing
 instances of type beanType.
 Instantiator is
 registered when module is registered for ObjectMapper.
public SimpleModule setMixInAnnotation(Class<?> targetType, Class<?> mixinClass)
mixinClass
 should be "mixed in" with annotations that targetType
 has (as if they were directly included on it!).
 Mix-in annotations are
 registered when module is registered for ObjectMapper.
public String getModuleName()
ModulegetModuleName in class Modulepublic void setupModule(Module.SetupContext context)
setupModule in class Modulepublic Version version()
ModuleCopyright © 2008–2020 FasterXML. All rights reserved.