Class AbstractTypeMaterializer
java.lang.Object
com.fasterxml.jackson.databind.AbstractTypeResolver
com.fasterxml.jackson.module.mrbean.AbstractTypeMaterializer
- All Implemented Interfaces:
com.fasterxml.jackson.core.Versioned
public class AbstractTypeMaterializer
extends com.fasterxml.jackson.databind.AbstractTypeResolver
implements com.fasterxml.jackson.core.Versioned
Nifty class for pulling implementations of classes out of thin air.
... friends call him Mister Bean... :-)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Enumeration that defines togglable features that guide the serialization feature.(package private) static class
To support actual dynamic loading of bytecode we need a simple custom classloader. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AbstractTypeMaterializer.MyClassLoader
We will use per-materializer class loader for now; would be nice to find a way to reduce number of class loaders (and hence number of generated classes!) constructed...protected String
Package name to use as prefix for generated classes.protected int
Bit set that contains all enabled featuresprotected static final int
Bitfield (set of flags) of all Features that are enabled by default.static final String
Default package to use for generated classes. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Class
<?> _loadAndResolve
(String className, byte[] bytecode, Class<?> rawType) protected Class
<?> _materializeRawType
(com.fasterxml.jackson.databind.cfg.MapperConfig<?> config, com.fasterxml.jackson.databind.introspect.AnnotatedClass typeDef, String nameToUse) protected boolean
_suitableType
(com.fasterxml.jackson.databind.JavaType type) Overridable helper method called to check if given non-concrete type should be materialized.void
Method for disabling specified feature.void
Method for enabling specified feature.final boolean
Method for checking whether given feature is enabled or notClass
<?> materializeGenericType
(com.fasterxml.jackson.databind.cfg.MapperConfig<?> config, com.fasterxml.jackson.databind.JavaType type) Class
<?> materializeRawType
(com.fasterxml.jackson.databind.cfg.MapperConfig<?> config, com.fasterxml.jackson.databind.introspect.AnnotatedClass typeDef) NOTE: should not be called for generic types.com.fasterxml.jackson.databind.JavaType
resolveAbstractType
(com.fasterxml.jackson.databind.DeserializationConfig config, com.fasterxml.jackson.databind.BeanDescription beanDesc) Entry-point forAbstractTypeResolver
that Jackson calls to materialize an abstract type.void
set
(AbstractTypeMaterializer.Feature f, boolean state) Method for enabling or disabling specified feature.void
setDefaultPackage
(String defPkg) Method for specifying package to use for generated classes.com.fasterxml.jackson.core.Version
version()
Method that will return version information stored in and read from jar that contains this class.Methods inherited from class com.fasterxml.jackson.databind.AbstractTypeResolver
findTypeMapping, resolveAbstractType
-
Field Details
-
DEFAULT_FEATURE_FLAGS
protected static final int DEFAULT_FEATURE_FLAGSBitfield (set of flags) of all Features that are enabled by default. -
DEFAULT_PACKAGE_FOR_GENERATED
Default package to use for generated classes.- See Also:
-
_classLoader
We will use per-materializer class loader for now; would be nice to find a way to reduce number of class loaders (and hence number of generated classes!) constructed... -
_featureFlags
protected int _featureFlagsBit set that contains all enabled features -
_defaultPackage
Package name to use as prefix for generated classes.
-
-
Constructor Details
-
AbstractTypeMaterializer
public AbstractTypeMaterializer() -
AbstractTypeMaterializer
- Parameters:
parentClassLoader
- Class loader to use for generated classes; if null, will use class loader that loaded materializer itself.
-
-
Method Details
-
version
public com.fasterxml.jackson.core.Version version()Method that will return version information stored in and read from jar that contains this class.- Specified by:
version
in interfacecom.fasterxml.jackson.core.Versioned
-
isEnabled
Method for checking whether given feature is enabled or not -
enable
Method for enabling specified feature. -
disable
Method for disabling specified feature. -
set
Method for enabling or disabling specified feature. -
setDefaultPackage
Method for specifying package to use for generated classes. -
resolveAbstractType
public com.fasterxml.jackson.databind.JavaType resolveAbstractType(com.fasterxml.jackson.databind.DeserializationConfig config, com.fasterxml.jackson.databind.BeanDescription beanDesc) Entry-point forAbstractTypeResolver
that Jackson calls to materialize an abstract type.- Overrides:
resolveAbstractType
in classcom.fasterxml.jackson.databind.AbstractTypeResolver
-
materializeGenericType
public Class<?> materializeGenericType(com.fasterxml.jackson.databind.cfg.MapperConfig<?> config, com.fasterxml.jackson.databind.JavaType type) - Since:
- 2.4
-
materializeRawType
public Class<?> materializeRawType(com.fasterxml.jackson.databind.cfg.MapperConfig<?> config, com.fasterxml.jackson.databind.introspect.AnnotatedClass typeDef) NOTE: should not be called for generic types.- Since:
- 2.4
-
_materializeRawType
-
_loadAndResolve
-
_suitableType
protected boolean _suitableType(com.fasterxml.jackson.databind.JavaType type) Overridable helper method called to check if given non-concrete type should be materialized.Default implementation will blocks all
- primitive types
Enums
- Container types (Collections, Maps; as per Jackson "container type")
- Reference types (Jackson definition
Jackson 2.12 and earlier enumerated a small set of other types under
java.lang
andjava.util
: 2.13 and later simply block all types injava.*
.- Parameters:
type
- Type that we are asked to materialize- Returns:
- True if materialization should proceed;
false
if not.
-