Interface Module.SetupContext
-
- Enclosing class:
- Module
public static interface Module.SetupContextInterface Jackson exposes to modules for purpose of registering extended functionality. Usually implemented byObjectMapper, but modules should NOT rely on this -- if they do require access to mapper instance, they need to callgetOwner()method.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddAbstractTypeResolver(AbstractTypeResolver resolver)Method that module can use to register additionalAbstractTypeResolverinstance, to handle resolution of abstract to concrete types (either by defaulting, or by materializing).voidaddBeanDeserializerModifier(BeanDeserializerModifier mod)Method that module can use to register additional modifier objects to customize configuration and construction of bean deserializers.voidaddBeanSerializerModifier(BeanSerializerModifier mod)Method that module can use to register additional modifier objects to customize configuration and construction of bean serializers.voidaddDeserializationProblemHandler(DeserializationProblemHandler handler)Add a deserialization problem handlervoidaddDeserializers(Deserializers d)Method that module can use to register additional deserializers to use for handling types.voidaddKeyDeserializers(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)voidaddKeySerializers(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 writeJsonToken.FIELD_NAMEinstead of String value).voidaddSerializers(Serializers s)Method that module can use to register additional serializers to use for handling types.voidaddTypeModifier(TypeModifier modifier)Method that module can use to register additionalTypeModifierinstance, which can augmentJavaTypeinstances constructed byTypeFactory.voidaddValueInstantiators(ValueInstantiators instantiators)Method that module can use to register additionalValueInstantiators, by addingValueInstantiatorsobject that gets called when instantatiator is needed by a deserializer.voidappendAnnotationIntrospector(AnnotationIntrospector ai)Method for registering specifiedAnnotationIntrospectoras the lowest priority introspector, chained with existing introspector(s) and called as fallback for cases not otherwise handled.MutableConfigOverrideconfigOverride(java.lang.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.VersiongetMapperVersion()Method that returns version information aboutObjectMapperthat implements this context.<C extends ObjectCodec>
CgetOwner()Fallback access method that allows modules to refer to theObjectMapperthat provided this context.TypeFactorygetTypeFactory()Accessor for findingTypeFactorythat is currently configured by the context.voidinsertAnnotationIntrospector(AnnotationIntrospector ai)Method for registering specifiedAnnotationIntrospectoras the highest priority introspector (will be chained with existing introspector(s) which will be used as fallbacks for cases this introspector does not handle)booleanisEnabled(JsonFactory.Feature f)booleanisEnabled(JsonGenerator.Feature f)booleanisEnabled(JsonParser.Feature f)booleanisEnabled(DeserializationFeature f)booleanisEnabled(MapperFeature f)booleanisEnabled(SerializationFeature f)voidregisterSubtypes(NamedType... subtypes)Method for registering specified classes as subtypes (of supertype(s) they have), using specified type names.voidregisterSubtypes(java.lang.Class<?>... subtypes)Method for registering specified classes as subtypes (of supertype(s) they have)voidregisterSubtypes(java.util.Collection<java.lang.Class<?>> subtypes)Method for registering specified classes as subtypes (of supertype(s) they have)voidsetClassIntrospector(ClassIntrospector ci)Method for replacing the default class introspector with a derived class that overrides specific behavior.voidsetMixInAnnotations(java.lang.Class<?> target, java.lang.Class<?> mixinSource)Method used for defining mix-in annotations to use for augmenting specified class or interface.voidsetNamingStrategy(PropertyNamingStrategy naming)Method that may be used to override naming strategy that is used byObjectMapper.
-
-
-
Method Detail
-
getMapperVersion
Version getMapperVersion()
Method that returns version information aboutObjectMapperthat 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.
-
getOwner
<C extends ObjectCodec> C getOwner()
Fallback access method that allows modules to refer to theObjectMapperthat 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
-
getTypeFactory
TypeFactory getTypeFactory()
Accessor for findingTypeFactorythat 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
-
isEnabled
boolean isEnabled(MapperFeature f)
-
isEnabled
boolean isEnabled(DeserializationFeature f)
-
isEnabled
boolean isEnabled(SerializationFeature f)
-
isEnabled
boolean isEnabled(JsonFactory.Feature f)
-
isEnabled
boolean isEnabled(JsonParser.Feature f)
-
isEnabled
boolean isEnabled(JsonGenerator.Feature f)
-
configOverride
MutableConfigOverride configOverride(java.lang.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 domapper.configOverride(java.util.Date.class) .setFormat(JsonFormat.Value.forPattern("yyyy-MM-dd"));to change the default format to use for properties of typeDate(possibly further overridden by per-property annotations)- Since:
- 2.8
-
addDeserializers
void addDeserializers(Deserializers d)
Method that module can use to register additional deserializers to use for handling types.- Parameters:
d- Object that can be called to find deserializer for types supported by module (null returned for non-supported types)
-
addKeyDeserializers
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)
-
addSerializers
void addSerializers(Serializers s)
Method that module can use to register additional serializers to use for handling types.- Parameters:
s- Object that can be called to find serializer for types supported by module (null returned for non-supported types)
-
addKeySerializers
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 writeJsonToken.FIELD_NAMEinstead of String value).
-
addBeanDeserializerModifier
void addBeanDeserializerModifier(BeanDeserializerModifier mod)
Method that module can use to register additional modifier objects to customize configuration and construction of bean deserializers.- Parameters:
mod- Modifier to register
-
addBeanSerializerModifier
void addBeanSerializerModifier(BeanSerializerModifier mod)
Method that module can use to register additional modifier objects to customize configuration and construction of bean serializers.- Parameters:
mod- Modifier to register
-
addAbstractTypeResolver
void addAbstractTypeResolver(AbstractTypeResolver resolver)
Method that module can use to register additionalAbstractTypeResolverinstance, to handle resolution of abstract to concrete types (either by defaulting, or by materializing).- Parameters:
resolver- Resolver to add.
-
addTypeModifier
void addTypeModifier(TypeModifier modifier)
Method that module can use to register additionalTypeModifierinstance, which can augmentJavaTypeinstances constructed byTypeFactory.- Parameters:
modifier- to add
-
addValueInstantiators
void addValueInstantiators(ValueInstantiators instantiators)
Method that module can use to register additionalValueInstantiators, by addingValueInstantiatorsobject that gets called when instantatiator is needed by a deserializer.- Parameters:
instantiators- Object that can provideValueInstantiators for constructing POJO values during deserialization
-
setClassIntrospector
void setClassIntrospector(ClassIntrospector ci)
Method for replacing the default class introspector with a derived class that overrides specific behavior.- Parameters:
ci- Derived class of ClassIntrospector with overriden behavior- Since:
- 2.2
-
insertAnnotationIntrospector
void insertAnnotationIntrospector(AnnotationIntrospector ai)
Method for registering specifiedAnnotationIntrospectoras 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- Annotation introspector to register.
-
appendAnnotationIntrospector
void appendAnnotationIntrospector(AnnotationIntrospector ai)
Method for registering specifiedAnnotationIntrospectoras the lowest priority introspector, chained with existing introspector(s) and called as fallback for cases not otherwise handled.- Parameters:
ai- Annotation introspector to register.
-
registerSubtypes
void registerSubtypes(java.lang.Class<?>... subtypes)
Method for registering specified classes as subtypes (of supertype(s) they have)
-
registerSubtypes
void registerSubtypes(NamedType... subtypes)
Method for registering specified classes as subtypes (of supertype(s) they have), using specified type names.
-
registerSubtypes
void registerSubtypes(java.util.Collection<java.lang.Class<?>> subtypes)
Method for registering specified classes as subtypes (of supertype(s) they have)- Since:
- 2.9
-
setMixInAnnotations
void setMixInAnnotations(java.lang.Class<?> target, java.lang.Class<?> mixinSource)Method used for defining mix-in annotations to use for augmenting specified class or interface. All annotations frommixinSourceare taken to override annotations thattarget(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 (or interface) whose annotations to effectively overridemixinSource- Class (or interface) whose annotations are to be "added" to target's annotations, overriding as necessary
-
addDeserializationProblemHandler
void addDeserializationProblemHandler(DeserializationProblemHandler handler)
Add a deserialization problem handler- Parameters:
handler- The deserialization problem handler
-
setNamingStrategy
void setNamingStrategy(PropertyNamingStrategy naming)
Method that may be used to override naming strategy that is used byObjectMapper.- Since:
- 2.3
-
-