com.fasterxml.jackson.databind.module

## Class SimpleModule

- java.lang.Object
- - com.fasterxml.jackson.databind.Module
  - - com.fasterxml.jackson.databind.module.SimpleModule

- All Implemented Interfaces:
    com.fasterxml.jackson.core.Versioned, java.io.Serializable

      public class SimpleModule
      extends Module
      implements java.io.Serializable

  Vanilla `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 `AbstractTypeResolver`s, `ValueInstantiator`s).

  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.

  See Also:
    Serialized Form

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class com.fasterxml.jackson.databind.Module

      `Module.SetupContext`

  - ### Field Summary

    Fields
    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` | `_deserializerModifier`
    `protected SimpleDeserializers` | `_deserializers`
    `protected SimpleKeyDeserializers` | `_keyDeserializers`
    `protected SimpleSerializers` | `_keySerializers`
    `protected java.util.HashMap<java.lang.Class<?>,java.lang.Class<?>>` | `_mixins` Lazily-constructed map that contains mix-in definitions, indexed by target class, value being mix-in to apply.
    `protected java.lang.String` | `_name`
    `protected PropertyNamingStrategy` | `_namingStrategy`
    `protected BeanSerializerModifier` | `_serializerModifier`
    `protected SimpleSerializers` | `_serializers`
    `protected java.util.LinkedHashSet<NamedType>` | `_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 com.fasterxml.jackson.core.Version` | `_version`

  - ### Constructor Summary

    Constructors
    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(java.lang.String name)` Convenience constructor that will default version to `Version.unknownVersion()`.
    `SimpleModule(java.lang.String name, com.fasterxml.jackson.core.Version version)` Constructor to use for actual reusable modules.
    `SimpleModule(java.lang.String name, com.fasterxml.jackson.core.Version version, java.util.List<JsonSerializer<?>> serializers)`
    `SimpleModule(java.lang.String name, com.fasterxml.jackson.core.Version version, java.util.Map<java.lang.Class<?>,JsonDeserializer<?>> deserializers)`
    `SimpleModule(java.lang.String name, com.fasterxml.jackson.core.Version version, java.util.Map<java.lang.Class<?>,JsonDeserializer<?>> deserializers, java.util.List<JsonSerializer<?>> serializers)`
    `SimpleModule(com.fasterxml.jackson.core.Version version)` Convenience constructor that will use specified Version, including name from `Version.getArtifactId()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `<T> SimpleModule` | `addAbstractTypeMapping(java.lang.Class<T> superType, java.lang.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(java.lang.Class<T> type, JsonDeserializer<? extends T> deser)`
    `SimpleModule` | `addKeyDeserializer(java.lang.Class<?> type, KeyDeserializer deser)`
    `<T> SimpleModule` | `addKeySerializer(java.lang.Class<? extends T> type, JsonSerializer<T> ser)`
    `<T> SimpleModule` | `addSerializer(java.lang.Class<? extends T> type, JsonSerializer<T> ser)`
    `SimpleModule` | `addSerializer(JsonSerializer<?> ser)`
    `SimpleModule` | `addValueInstantiator(java.lang.Class<?> beanType, ValueInstantiator inst)` Method for registering `ValueInstantiator` to use when deserializing instances of type `beanType`.
    `java.lang.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.
    `java.lang.Object` | `getTypeId()` Since instances are likely to be custom, implementation returns `null` if (but only if!) this class is directly instantiated; but class name (default impl) for sub-classes.
    `SimpleModule` | `registerSubtypes(java.lang.Class<?>... subtypes)` Method for adding set of subtypes to be registered with `ObjectMapper` this 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 `ObjectMapper` this 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(java.lang.Class<?> targetType, java.lang.Class<?> mixinClass)` Method for specifying that annotations define by `mixinClass` should be "mixed in" with annotations that `targetType` has (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
    `com.fasterxml.jackson.core.Version` | `version()` Method that returns version of this module.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### _name

          protected final java.lang.String _name

    - #### _version

          protected final com.fasterxml.jackson.core.Version _version

    - #### _serializers

          protected SimpleSerializers _serializers

    - #### _deserializers

          protected SimpleDeserializers _deserializers

    - #### _keySerializers

          protected SimpleSerializers _keySerializers

    - #### _keyDeserializers

          protected SimpleKeyDeserializers _keyDeserializers

    - #### _abstractTypes

          protected SimpleAbstractTypeResolver _abstractTypes

      Lazily-constructed resolver used for storing mappings from abstract classes to more specific implementing classes (which may be abstract or concrete)

    - #### _valueInstantiators

          protected SimpleValueInstantiators _valueInstantiators

      Lazily-constructed resolver used for storing mappings from abstract classes to more specific implementing classes (which may be abstract or concrete)

    - #### _deserializerModifier

          protected BeanDeserializerModifier _deserializerModifier

      Since:
        2.2

    - #### _serializerModifier

          protected BeanSerializerModifier _serializerModifier

      Since:
        2.2

    - #### _mixins

          protected java.util.HashMap<java.lang.Class<?>,java.lang.Class<?>> _mixins

      Lazily-constructed map that contains mix-in definitions, indexed by target class, value being mix-in to apply.

    - #### _subtypes

          protected java.util.LinkedHashSet<NamedType> _subtypes

      Set of subtypes to register, if any.

    - #### _namingStrategy

          protected PropertyNamingStrategy _namingStrategy

      Since:
        2.3

  - ### Constructor Detail

    - #### 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

          public SimpleModule(java.lang.String name)

      Convenience constructor that will default version to `Version.unknownVersion()`.

    - #### SimpleModule

          public SimpleModule(com.fasterxml.jackson.core.Version version)

      Convenience constructor that will use specified Version, including name from `Version.getArtifactId()`

    - #### SimpleModule

          public SimpleModule(java.lang.String name,
                      com.fasterxml.jackson.core.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).
      Parameters:
        `name` - Unique name of the module
        `version` - Version of the module

    - #### SimpleModule

          public SimpleModule(java.lang.String name,
                      com.fasterxml.jackson.core.Version version,
                      java.util.Map<java.lang.Class<?>,JsonDeserializer<?>> deserializers)

      Since:
        2.1

    - #### SimpleModule

          public SimpleModule(java.lang.String name,
                      com.fasterxml.jackson.core.Version version,
                      java.util.List<JsonSerializer<?>> serializers)

      Since:
        2.1

    - #### SimpleModule

          public SimpleModule(java.lang.String name,
                      com.fasterxml.jackson.core.Version version,
                      java.util.Map<java.lang.Class<?>,JsonDeserializer<?>> deserializers,
                      java.util.List<JsonSerializer<?>> serializers)

      Since:
        2.1

  - ### Method Detail

    - #### getTypeId

          public java.lang.Object getTypeId()

      Since instances are likely to be custom, implementation returns `null` if (but only if!) this class is directly instantiated; but class name (default impl) for sub-classes.
      Overrides:
        `getTypeId` in class `Module`

    - #### setSerializers

          public void setSerializers(SimpleSerializers s)

      Resets all currently configured serializers.

    - #### setDeserializers

          public void setDeserializers(SimpleDeserializers d)

      Resets all currently configured deserializers.

    - #### setKeySerializers

          public void setKeySerializers(SimpleSerializers ks)

      Resets all currently configured key serializers.

    - #### setKeyDeserializers

          public void setKeyDeserializers(SimpleKeyDeserializers kd)

      Resets all currently configured key deserializers.

    - #### setAbstractTypes

          public void setAbstractTypes(SimpleAbstractTypeResolver atr)

      Resets currently configured abstract type mappings

    - #### setValueInstantiators

          public void setValueInstantiators(SimpleValueInstantiators svi)

      Resets all currently configured value instantiators

    - #### setDeserializerModifier

          public SimpleModule setDeserializerModifier(BeanDeserializerModifier mod)

      Since:
        2.2

    - #### setSerializerModifier

          public SimpleModule setSerializerModifier(BeanSerializerModifier mod)

      Since:
        2.2

    - #### setNamingStrategy

          protected SimpleModule setNamingStrategy(PropertyNamingStrategy naming)

      Since:
        2.3

    - #### addSerializer

          public SimpleModule addSerializer(JsonSerializer<?> ser)

    - #### addSerializer

          public <T> SimpleModule addSerializer(java.lang.Class<? extends T> type,
                                       JsonSerializer<T> ser)

    - #### addKeySerializer

          public <T> SimpleModule addKeySerializer(java.lang.Class<? extends T> type,
                                          JsonSerializer<T> ser)

    - #### addDeserializer

          public <T> SimpleModule addDeserializer(java.lang.Class<T> type,
                                         JsonDeserializer<? extends T> deser)

    - #### addKeyDeserializer

          public SimpleModule addKeyDeserializer(java.lang.Class<?> type,
                                        KeyDeserializer deser)

    - #### addAbstractTypeMapping

          public <T> SimpleModule addAbstractTypeMapping(java.lang.Class<T> superType,
                                                java.lang.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)

    - #### addValueInstantiator

          public SimpleModule addValueInstantiator(java.lang.Class<?> beanType,
                                          ValueInstantiator inst)

      Method for registering `ValueInstantiator` to use when deserializing instances of type `beanType`.

      Instantiator is registered when module is registered for `ObjectMapper`.

    - #### registerSubtypes

          public SimpleModule registerSubtypes(java.lang.Class<?>... subtypes)

      Method for adding set of subtypes to be registered with `ObjectMapper` this is an alternative to using annotations in super type to indicate subtypes.

    - #### registerSubtypes

          public SimpleModule registerSubtypes(NamedType... subtypes)

      Method for adding set of subtypes (along with type name to use) to be registered with `ObjectMapper` this is an alternative to using annotations in super type to indicate subtypes.

    - #### setMixInAnnotation

          public SimpleModule setMixInAnnotation(java.lang.Class<?> targetType,
                                        java.lang.Class<?> mixinClass)

      Method for specifying that annotations define by `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`.

    - #### getModuleName

          public java.lang.String getModuleName()

      Description copied from class: `Module`
      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.
      Specified by:
        `getModuleName` in class `Module`

    - #### setupModule

          public 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.
      Specified by:
        `setupModule` in class `Module`

    - #### version

          public com.fasterxml.jackson.core.Version version()

      Description copied from class: `Module`
      Method that returns version of this module. Can be used by Jackson for informational purposes.
      Specified by:
        `version` in interface `com.fasterxml.jackson.core.Versioned`
      Specified by:
        `version` in class `Module`