Top Description Inners Constructors Methods
com.fasterxml.jackson.databind

public abstract Class Module

extends Object
implements Versioned
Class Inheritance
All Implemented Interfaces
com.fasterxml.jackson.core.Versioned
Known Direct Subclasses
com.fasterxml.jackson.databind.module.SimpleModule
Imports
java.util.Collection, .Collections, com.fasterxml.jackson.core.*, com.fasterxml.jackson.databind.cfg.MutableConfigOverride, com.fasterxml.jackson.databind.deser.BeanDeserializerModifier, .DeserializationProblemHandler, .Deserializers, .KeyDeserializers, .ValueInstantiators, com.fasterxml.jackson.databind.introspect.ClassIntrospector, com.fasterxml.jackson.databind.jsontype.NamedType, com.fasterxml.jackson.databind.ser.BeanSerializerModifier, .Serializers, com.fasterxml.jackson.databind.type.TypeFactory, .TypeModifier

Simple interface for extensions that can be registered with ObjectMapper to provide a well-defined set of extensions to default functionality; such as support for new data types.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
Module.SetupContext

Interface Jackson exposes to modules for purpose of registering extended functionality.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Iterable<? extends Module>
getDependencies()

Returns the list of dependent modules this module has, if any.

public abstract 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.

public Object
getTypeId()

Method that returns an id that may be used to determine if two Module instances are considered to be of same type, for purpose of preventing multiple registrations of "same type of" module (see com.fasterxml.jackson.databind.MapperFeature#IGNORE_DUPLICATE_MODULE_REGISTRATIONS) If `null` is returned, every instance is considered unique.

public abstract void
setupModule(Module.SetupContext context)

Method called by ObjectMapper when module is registered.

public abstract Version
version()

Redeclares com.fasterxml.jackson.core.Versioned.version.

Method that returns version of this module.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Moduleback to summary
public Module()

Method Detail

getDependenciesback to summary
public Iterable<? extends Module> getDependencies()

Returns the list of dependent modules this module has, if any. It is called to let modules register other modules as dependencies. Modules returned will be registered before this module is registered, in iteration order.

Since
2.10
getModuleNameback to summary
public abstract 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.

getTypeIdback to summary
public Object getTypeId()

Method that returns an id that may be used to determine if two Module instances are considered to be of same type, for purpose of preventing multiple registrations of "same type of" module (see com.fasterxml.jackson.databind.MapperFeature#IGNORE_DUPLICATE_MODULE_REGISTRATIONS) If `null` is returned, every instance is considered unique. If non-null value is returned, equality of id Objects is used to check whether modules should be considered to be "of same type"

Default implementation returns value of class name (Class#getName).

Since
2.5
setupModuleback to summary
public abstract void setupModule(Module.SetupContext context)

Method called by ObjectMapper when module is registered. It is called to let module register functionality it provides, using callback methods passed-in context object exposes.

versionback to summary
public abstract Version version()

Redeclares com.fasterxml.jackson.core.Versioned.version.

Method that returns version of this module. Can be used by Jackson for informational purposes.

Returns:Version

Doc from com.fasterxml.jackson.core.Versioned.version.

Version of the component

Annotations
@Override
com.fasterxml.jackson.databind back to summary

public Interface Module.SetupContext


Interface Jackson exposes to modules for purpose of registering extended functionality. Usually implemented by ObjectMapper, but modules should NOT rely on this -- if they do require access to mapper instance, they need to call SetupContext#getOwner method.

Method Summary

Modifier and TypeMethod and Description
public void
addAbstractTypeResolver(AbstractTypeResolver
Resolver to add.
resolver
)

Method that module can use to register additional AbstractTypeResolver instance, to handle resolution of abstract to concrete types (either by defaulting, or by materializing).

public void
addBeanDeserializerModifier(BeanDeserializerModifier
Modifier to register
mod
)

Method that module can use to register additional modifier objects to customize configuration and construction of bean deserializers.

public void
addBeanSerializerModifier(BeanSerializerModifier
Modifier to register
mod
)

Method that module can use to register additional modifier objects to customize configuration and construction of bean serializers.

public void
addDeserializationProblemHandler(DeserializationProblemHandler
The deserialization problem handler
handler
)

Add a deserialization problem handler

public void
addDeserializers(Deserializers
Object that can be called to find deserializer for types supported by module (null returned for non-supported types)
d
)

Method that module can use to register additional deserializers to use for handling types.

public void
addKeyDeserializers(KeyDeserializers s)

Method that module can use to register additional deserializers to use for handling Map key values (which are separate from value deserializers because they are always serialized from String values)

public void
addKeySerializers(Serializers s)

Method that module can use to register additional serializers to use for handling Map key values (which are separate from value serializers because they must write JsonToken.FIELD_NAME instead of String value).

public void
addSerializers(Serializers
Object that can be called to find serializer for types supported by module (null returned for non-supported types)
s
)

Method that module can use to register additional serializers to use for handling types.

public void
addTypeModifier(TypeModifier
to add
modifier
)

Method that module can use to register additional TypeModifier instance, which can augment com.fasterxml.jackson.databind.JavaType instances constructed by com.fasterxml.jackson.databind.type.TypeFactory.

public void
addValueInstantiators(ValueInstantiators
Object that can provide com.fasterxml.jackson.databind.deser.ValueInstantiators for constructing POJO values during deserialization
instantiators
)

Method that module can use to register additional com.fasterxml.jackson.databind.deser.ValueInstantiators, by adding ValueInstantiators object that gets called when instantatiator is needed by a deserializer.

public void
appendAnnotationIntrospector(AnnotationIntrospector
Annotation introspector to register.
ai
)

Method for registering specified AnnotationIntrospector as the lowest priority introspector, chained with existing introspector(s) and called as fallback for cases not otherwise handled.

public MutableConfigOverride
configOverride(Class<?> type)

"Mutant accessor" for getting a mutable configuration override object for given type, needed to add or change per-type overrides applied to properties of given type.

public Version
getMapperVersion()

Method that returns version information about ObjectMapper that implements this context.

public <C extends ObjectCodec> C
getOwner()

Fallback access method that allows modules to refer to the ObjectMapper that provided this context.

public TypeFactory
getTypeFactory()

Accessor for finding TypeFactory that is currently configured by the context.

public void
insertAnnotationIntrospector(AnnotationIntrospector
Annotation introspector to register.
ai
)

Method for registering specified AnnotationIntrospector as the highest priority introspector (will be chained with existing introspector(s) which will be used as fallbacks for cases this introspector does not handle)

public boolean
public boolean
public boolean
public boolean
public boolean
public boolean
public void
registerSubtypes(Class<?>... subtypes)

Method for registering specified classes as subtypes (of supertype(s) they have)

public void
registerSubtypes(NamedType... subtypes)

Method for registering specified classes as subtypes (of supertype(s) they have), using specified type names.

public void
registerSubtypes(Collection<Class<?>> subtypes)

Method for registering specified classes as subtypes (of supertype(s) they have)

public void
setClassIntrospector(ClassIntrospector
Derived class of ClassIntrospector with overriden behavior
ci
)

Method for replacing the default class introspector with a derived class that overrides specific behavior.

public void
setMixInAnnotations(Class<?>
Class (or interface) whose annotations to effectively override
target
,
Class<?>
Class (or interface) whose annotations are to be "added" to target's annotations, overriding as necessary
mixinSource
)

Method used for defining mix-in annotations to use for augmenting specified class or interface.

public void
setNamingStrategy(PropertyNamingStrategy naming)

Method that may be used to override naming strategy that is used by ObjectMapper.

Method Detail

addAbstractTypeResolverback to summary
public void addAbstractTypeResolver(AbstractTypeResolver resolver)

Method that module can use to register additional AbstractTypeResolver instance, to handle resolution of abstract to concrete types (either by defaulting, or by materializing).

Parameters
resolver:AbstractTypeResolver

Resolver to add.

addBeanDeserializerModifierback to summary
public void addBeanDeserializerModifier(BeanDeserializerModifier mod)

Method that module can use to register additional modifier objects to customize configuration and construction of bean deserializers.

Parameters
mod:BeanDeserializerModifier

Modifier to register

addBeanSerializerModifierback to summary
public void addBeanSerializerModifier(BeanSerializerModifier mod)

Method that module can use to register additional modifier objects to customize configuration and construction of bean serializers.

Parameters
mod:BeanSerializerModifier

Modifier to register

addDeserializationProblemHandlerback to summary
public void addDeserializationProblemHandler(DeserializationProblemHandler handler)

Add a deserialization problem handler

Parameters
handler:DeserializationProblemHandler

The deserialization problem handler

addDeserializersback to summary
public void addDeserializers(Deserializers d)

Method that module can use to register additional deserializers to use for handling types.

Parameters
d:Deserializers

Object that can be called to find deserializer for types supported by module (null returned for non-supported types)

See Also
is used to register key deserializers (for Map keys)
addKeyDeserializersback to summary
public void addKeyDeserializers(KeyDeserializers s)

Method that module can use to register additional deserializers to use for handling Map key values (which are separate from value deserializers because they are always serialized from String values)

addKeySerializersback to summary
public void addKeySerializers(Serializers s)

Method that module can use to register additional serializers to use for handling Map key values (which are separate from value serializers because they must write JsonToken.FIELD_NAME instead of String value).

addSerializersback to summary
public void addSerializers(Serializers s)

Method that module can use to register additional serializers to use for handling types.

Parameters
s:Serializers

Object that can be called to find serializer for types supported by module (null returned for non-supported types)

See Also
is used to register key serializers (for Map keys)
addTypeModifierback to summary
public void addTypeModifier(TypeModifier modifier)

Method that module can use to register additional TypeModifier instance, which can augment com.fasterxml.jackson.databind.JavaType instances constructed by com.fasterxml.jackson.databind.type.TypeFactory.

Parameters
modifier:TypeModifier

to add

addValueInstantiatorsback to summary
public void addValueInstantiators(ValueInstantiators instantiators)

Method that module can use to register additional com.fasterxml.jackson.databind.deser.ValueInstantiators, by adding ValueInstantiators object that gets called when instantatiator is needed by a deserializer.

Parameters
instantiators:ValueInstantiators

Object that can provide com.fasterxml.jackson.databind.deser.ValueInstantiators for constructing POJO values during deserialization

appendAnnotationIntrospectorback to summary
public void appendAnnotationIntrospector(AnnotationIntrospector ai)

Method for registering specified AnnotationIntrospector as the lowest priority introspector, chained with existing introspector(s) and called as fallback for cases not otherwise handled.

Parameters
ai:AnnotationIntrospector

Annotation introspector to register.

configOverrideback to summary
public MutableConfigOverride configOverride(Class<?> type)

"Mutant accessor" for getting a mutable configuration override object for given type, needed to add or change per-type overrides applied to properties of given type. Usage is through returned object by colling "setter" methods, which directly modify override object and take effect directly. For example you can do

   mapper.configOverride(java.util.Date.class)
       .setFormat(JsonFormat.Value.forPattern("yyyy-MM-dd"));
to change the default format to use for properties of type java.util.Date (possibly further overridden by per-property annotations)
Since
2.8
getMapperVersionback to summary
public Version getMapperVersion()

Method that returns version information about ObjectMapper that implements this context. Modules can use this to choose different settings or initialization order; or even decide to fail set up completely if version is compatible with module.

getOwnerback to summary
public <C extends ObjectCodec> C getOwner()

Fallback access method that allows modules to refer to the ObjectMapper that provided this context. It should NOT be needed by most modules; and ideally should not be used -- however, there may be cases where this may be necessary due to various design constraints.

Note

use of this method is discouraged, as it allows access to things Modules typically should not modify. It is included, however, to allow access to new features in cases where Module API has not yet been extended, or there are oversights.

Return value is chosen to not leak dependency to ObjectMapper; however, instance will always be of that type. This is why return value is declared generic, to allow caller to specify context to often avoid casting.

Since
2.0
getTypeFactoryback to summary
public TypeFactory getTypeFactory()

Accessor for finding TypeFactory that is currently configured by the context.

Note

since it is possible that other modules might change or replace TypeFactory, use of this method adds order-dependency for registrations.

Since
2.0
insertAnnotationIntrospectorback to summary
public void insertAnnotationIntrospector(AnnotationIntrospector ai)

Method for registering specified AnnotationIntrospector as the highest priority introspector (will be chained with existing introspector(s) which will be used as fallbacks for cases this introspector does not handle)

Parameters
ai:AnnotationIntrospector

Annotation introspector to register.

isEnabledback to summary
public boolean isEnabled(MapperFeature f)
isEnabledback to summary
public boolean isEnabled(DeserializationFeature f)
isEnabledback to summary
public boolean isEnabled(SerializationFeature f)
isEnabledback to summary
public boolean isEnabled(JsonFactory.Feature f)
isEnabledback to summary
public boolean isEnabled(JsonParser.Feature f)
isEnabledback to summary
public boolean isEnabled(JsonGenerator.Feature f)
registerSubtypesback to summary
public void registerSubtypes(Class<?>... subtypes)

Method for registering specified classes as subtypes (of supertype(s) they have)

registerSubtypesback to summary
public void registerSubtypes(NamedType... subtypes)

Method for registering specified classes as subtypes (of supertype(s) they have), using specified type names.

registerSubtypesback to summary
public void registerSubtypes(Collection<Class<?>> subtypes)

Method for registering specified classes as subtypes (of supertype(s) they have)

Since
2.9
setClassIntrospectorback to summary
public void setClassIntrospector(ClassIntrospector ci)

Method for replacing the default class introspector with a derived class that overrides specific behavior.

Parameters
ci:ClassIntrospector

Derived class of ClassIntrospector with overriden behavior

Since
2.2
setMixInAnnotationsback to summary
public void setMixInAnnotations(Class<?> target, Class<?> mixinSource)

Method used for defining mix-in annotations to use for augmenting specified class or interface. All annotations from mixinSource are taken to override annotations that target (or its supertypes) has.

Note

mix-ins are registered both for serialization and deserialization (which can be different internally).

Note

currently only one set of mix-in annotations can be defined for a single class; so if multiple modules register mix-ins, highest priority one (last one registered) will have priority over other modules.

Parameters
target:Class<?>

Class (or interface) whose annotations to effectively override

mixinSource:Class<?>

Class (or interface) whose annotations are to be "added" to target's annotations, overriding as necessary

setNamingStrategyback to summary
public void setNamingStrategy(PropertyNamingStrategy naming)

Method that may be used to override naming strategy that is used by ObjectMapper.

Since
2.3