Class HandlerInstantiator
- java.lang.Object
-
- com.fasterxml.jackson.databind.cfg.HandlerInstantiator
-
public abstract class HandlerInstantiator extends java.lang.Object
Helper class used for handling details of creating handler instances (things likeJsonSerializer
s,JsonDeserializer
s, various type handlers) of specific types. Actual handler type has been resolved at this point, so instantiator is strictly responsible for providing a configured instance by constructing and configuring a new instance, or possibly by recycling a shared instance. One use case is that of allowing dependency injection, which would otherwise be difficult to do.Custom instances are allowed to return null to indicate that caller should use the default instantiation handling (which just means calling no-argument constructor via reflection).
Care has to be taken to ensure that if instance returned is shared, it will be thread-safe; caller will not synchronize access to returned instances.
-
-
Constructor Summary
Constructors Constructor Description HandlerInstantiator()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Converter<?,?>
converterInstance(MapperConfig<?> config, Annotated annotated, java.lang.Class<?> implClass)
Method called to construct a Converter instance used for specified class.abstract JsonDeserializer<?>
deserializerInstance(DeserializationConfig config, Annotated annotated, java.lang.Class<?> deserClass)
Method called to get an instance of deserializer of specified type.java.lang.Object
includeFilterInstance(SerializationConfig config, BeanPropertyDefinition forProperty, java.lang.Class<?> filterClass)
Method called to construct a Filter (any Object with implementation ofequals(Object)
that determines if given value is to be excluded (true) or included (false)) to be used based onJsonInclude
annotation (or equivalent).abstract KeyDeserializer
keyDeserializerInstance(DeserializationConfig config, Annotated annotated, java.lang.Class<?> keyDeserClass)
Method called to get an instance of key deserializer of specified type.PropertyNamingStrategy
namingStrategyInstance(MapperConfig<?> config, Annotated annotated, java.lang.Class<?> implClass)
Method called to construct a NamingStrategy instance used for specified class.ObjectIdGenerator<?>
objectIdGeneratorInstance(MapperConfig<?> config, Annotated annotated, java.lang.Class<?> implClass)
Method called to construct a ObjectIdHandler instance of specified type.ObjectIdResolver
resolverIdGeneratorInstance(MapperConfig<?> config, Annotated annotated, java.lang.Class<?> implClass)
abstract JsonSerializer<?>
serializerInstance(SerializationConfig config, Annotated annotated, java.lang.Class<?> serClass)
Method called to get an instance of serializer of specified type.abstract TypeIdResolver
typeIdResolverInstance(MapperConfig<?> config, Annotated annotated, java.lang.Class<?> resolverClass)
Method called to get an instance of TypeIdResolver of specified type.abstract TypeResolverBuilder<?>
typeResolverBuilderInstance(MapperConfig<?> config, Annotated annotated, java.lang.Class<?> builderClass)
Method called to get an instance of TypeResolverBuilder of specified type.ValueInstantiator
valueInstantiatorInstance(MapperConfig<?> config, Annotated annotated, java.lang.Class<?> resolverClass)
Method called to construct an instance of ValueInstantiator of specified type.VirtualBeanPropertyWriter
virtualPropertyWriterInstance(MapperConfig<?> config, java.lang.Class<?> implClass)
Method called to construct aVirtualBeanPropertyWriter
instance of specified type.
-
-
-
Method Detail
-
deserializerInstance
public abstract JsonDeserializer<?> deserializerInstance(DeserializationConfig config, Annotated annotated, java.lang.Class<?> deserClass)
Method called to get an instance of deserializer of specified type.- Parameters:
config
- Deserialization configuration in effectannotated
- Element (Class, Method, Field, constructor parameter) that had annotation defining class of deserializer to construct (to allow implementation use information from other annotations)deserClass
- Class of deserializer instance to return- Returns:
- Deserializer instance to use
-
keyDeserializerInstance
public abstract KeyDeserializer keyDeserializerInstance(DeserializationConfig config, Annotated annotated, java.lang.Class<?> keyDeserClass)
Method called to get an instance of key deserializer of specified type.- Parameters:
config
- Deserialization configuration in effectannotated
- Element (Class, Method, Field, constructor parameter) that had annotation defining class of key deserializer to construct (to allow implementation use information from other annotations)keyDeserClass
- Class of key deserializer instance to return- Returns:
- Key deserializer instance to use
-
serializerInstance
public abstract JsonSerializer<?> serializerInstance(SerializationConfig config, Annotated annotated, java.lang.Class<?> serClass)
Method called to get an instance of serializer of specified type.- Parameters:
config
- Serialization configuration in effectannotated
- Element (Class, Method, Field) that had annotation defining class of serializer to construct (to allow implementation use information from other annotations)serClass
- Class of serializer instance to return- Returns:
- Serializer instance to use
-
typeResolverBuilderInstance
public abstract TypeResolverBuilder<?> typeResolverBuilderInstance(MapperConfig<?> config, Annotated annotated, java.lang.Class<?> builderClass)
Method called to get an instance of TypeResolverBuilder of specified type.- Parameters:
config
- Mapper configuration in effect (either SerializationConfig or DeserializationConfig, depending on when instance is being constructed)annotated
- annotated Element (Class, Method, Field) that had annotation defining class of builder to construct (to allow implementation use information from other annotations)builderClass
- Class of builder instance to return- Returns:
- TypeResolverBuilder instance to use
-
typeIdResolverInstance
public abstract TypeIdResolver typeIdResolverInstance(MapperConfig<?> config, Annotated annotated, java.lang.Class<?> resolverClass)
Method called to get an instance of TypeIdResolver of specified type.- Parameters:
config
- Mapper configuration in effect (either SerializationConfig or DeserializationConfig, depending on when instance is being constructed)annotated
- annotated Element (Class, Method, Field) that had annotation defining class of resolver to construct (to allow implementation use information from other annotations)resolverClass
- Class of resolver instance to return- Returns:
- TypeResolverBuilder instance to use
-
valueInstantiatorInstance
public ValueInstantiator valueInstantiatorInstance(MapperConfig<?> config, Annotated annotated, java.lang.Class<?> resolverClass)
Method called to construct an instance of ValueInstantiator of specified type.
-
objectIdGeneratorInstance
public ObjectIdGenerator<?> objectIdGeneratorInstance(MapperConfig<?> config, Annotated annotated, java.lang.Class<?> implClass)
Method called to construct a ObjectIdHandler instance of specified type.- Since:
- 2.0
-
resolverIdGeneratorInstance
public ObjectIdResolver resolverIdGeneratorInstance(MapperConfig<?> config, Annotated annotated, java.lang.Class<?> implClass)
-
namingStrategyInstance
public PropertyNamingStrategy namingStrategyInstance(MapperConfig<?> config, Annotated annotated, java.lang.Class<?> implClass)
Method called to construct a NamingStrategy instance used for specified class.- Since:
- 2.1
-
converterInstance
public Converter<?,?> converterInstance(MapperConfig<?> config, Annotated annotated, java.lang.Class<?> implClass)
Method called to construct a Converter instance used for specified class.- Since:
- 2.2
-
virtualPropertyWriterInstance
public VirtualBeanPropertyWriter virtualPropertyWriterInstance(MapperConfig<?> config, java.lang.Class<?> implClass)
Method called to construct aVirtualBeanPropertyWriter
instance of specified type.- Since:
- 2.5
-
includeFilterInstance
public java.lang.Object includeFilterInstance(SerializationConfig config, BeanPropertyDefinition forProperty, java.lang.Class<?> filterClass)
Method called to construct a Filter (any Object with implementation ofequals(Object)
that determines if given value is to be excluded (true) or included (false)) to be used based onJsonInclude
annotation (or equivalent).Default implementation returns `null` to indicate that default instantiation (use zero-arg constructor of the
filterClass
) should be used.- Since:
- 2.9
-
-