public static interface Module.SetupContext
ObjectMapper
, but modules should
NOT rely on this -- if they do require access to mapper instance,
they need to call getOwner()
method.Modifier and Type | Method and Description |
---|---|
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). |
void |
addBeanDeserializerModifier(BeanDeserializerModifier mod)
Method that module can use to register additional modifier objects to
customize configuration and construction of bean deserializers.
|
void |
addBeanSerializerModifier(BeanSerializerModifier mod)
Method that module can use to register additional modifier objects to
customize configuration and construction of bean serializers.
|
void |
addDeserializationProblemHandler(DeserializationProblemHandler handler)
Add a deserialization problem handler
|
void |
addDeserializers(Deserializers d)
Method that module can use to register additional deserializers to use for
handling types.
|
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)
|
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). |
void |
addSerializers(Serializers s)
Method that module can use to register additional serializers to use for
handling types.
|
void |
addTypeModifier(TypeModifier modifier)
Method that module can use to register additional
TypeModifier instance, which can augment JavaType
instances constructed by TypeFactory . |
void |
addValueInstantiators(ValueInstantiators instantiators)
Method that module can use to register additional
ValueInstantiator s,
by adding ValueInstantiators object that gets called when
instantatiator is needed by a deserializer. |
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. |
Version |
getMapperVersion()
Method that returns version information about
ObjectMapper
that implements this context. |
<C extends ObjectCodec> |
getOwner()
Fallback access method that allows modules to refer to the
ObjectMapper that provided this context. |
TypeFactory |
getTypeFactory()
Accessor for finding
TypeFactory that is currently configured
by the context. |
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) |
boolean |
isEnabled(DeserializationFeature f) |
boolean |
isEnabled(JsonFactory.Feature f) |
boolean |
isEnabled(JsonGenerator.Feature f) |
boolean |
isEnabled(JsonParser.Feature f) |
boolean |
isEnabled(MapperFeature f) |
boolean |
isEnabled(SerializationFeature f) |
void |
registerSubtypes(Class<?>... subtypes)
Method for registering specified classes as subtypes (of supertype(s)
they have)
|
void |
registerSubtypes(NamedType... subtypes)
Method for registering specified classes as subtypes (of supertype(s)
they have), using specified type names.
|
void |
setClassIntrospector(ClassIntrospector ci)
Method for replacing the default class introspector with a derived class that
overrides specific behavior.
|
void |
setMixInAnnotations(Class<?> target,
Class<?> mixinSource)
Method used for defining mix-in annotations to use for augmenting
specified class or interface.
|
void |
setNamingStrategy(PropertyNamingStrategy naming)
Method that may be used to override naming strategy that is used
by
ObjectMapper . |
Version getMapperVersion()
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.<C extends ObjectCodec> C getOwner()
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.
TypeFactory getTypeFactory()
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.
boolean isEnabled(MapperFeature f)
boolean isEnabled(DeserializationFeature f)
boolean isEnabled(SerializationFeature f)
boolean isEnabled(JsonFactory.Feature f)
boolean isEnabled(JsonParser.Feature f)
boolean isEnabled(JsonGenerator.Feature f)
void addDeserializers(Deserializers d)
d
- Object that can be called to find deserializer for types supported
by module (null returned for non-supported types)void addKeyDeserializers(KeyDeserializers s)
void addSerializers(Serializers s)
s
- Object that can be called to find serializer for types supported
by module (null returned for non-supported types)void addKeySerializers(Serializers s)
JsonToken.FIELD_NAME
instead of String value).void addBeanDeserializerModifier(BeanDeserializerModifier mod)
mod
- Modifier to registervoid addBeanSerializerModifier(BeanSerializerModifier mod)
mod
- Modifier to registervoid addAbstractTypeResolver(AbstractTypeResolver resolver)
AbstractTypeResolver
instance, to handle resolution of
abstract to concrete types (either by defaulting, or by materializing).resolver
- Resolver to add.void addTypeModifier(TypeModifier modifier)
TypeModifier
instance, which can augment JavaType
instances constructed by TypeFactory
.modifier
- to addvoid addValueInstantiators(ValueInstantiators instantiators)
ValueInstantiator
s,
by adding ValueInstantiators
object that gets called when
instantatiator is needed by a deserializer.instantiators
- Object that can provide ValueInstantiator
s for
constructing POJO values during deserializationvoid setClassIntrospector(ClassIntrospector ci)
ci
- Derived class of ClassIntrospector with overriden behaviorvoid insertAnnotationIntrospector(AnnotationIntrospector ai)
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)ai
- Annotation introspector to register.void appendAnnotationIntrospector(AnnotationIntrospector ai)
AnnotationIntrospector
as the lowest
priority introspector, chained with existing introspector(s) and called
as fallback for cases not otherwise handled.ai
- Annotation introspector to register.void registerSubtypes(Class<?>... subtypes)
void registerSubtypes(NamedType... subtypes)
void setMixInAnnotations(Class<?> target, Class<?> mixinSource)
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.
target
- Class (or interface) whose annotations to effectively overridemixinSource
- Class (or interface) whose annotations are to
be "added" to target's annotations, overriding as necessaryvoid addDeserializationProblemHandler(DeserializationProblemHandler handler)
handler
- The deserialization problem handlervoid setNamingStrategy(PropertyNamingStrategy naming)
ObjectMapper
.Copyright © 2014 FasterXML. All Rights Reserved.