Class 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... :-)

    Author:
    tatu, sunny
    • Field Detail

      • DEFAULT_FEATURE_FLAGS

        protected static final int DEFAULT_FEATURE_FLAGS
        Bitfield (set of flags) of all Features that are enabled by default.
      • DEFAULT_PACKAGE_FOR_GENERATED

        public static final String DEFAULT_PACKAGE_FOR_GENERATED
        Default package to use for generated classes.
        See Also:
        Constant Field Values
      • _classLoader

        protected final com.fasterxml.jackson.module.mrbean.AbstractTypeMaterializer.MyClassLoader _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 _featureFlags
        Bit set that contains all enabled features
      • _defaultPackage

        protected String _defaultPackage
        Package name to use as prefix for generated classes.
    • Constructor Detail

      • AbstractTypeMaterializer

        public AbstractTypeMaterializer()
      • AbstractTypeMaterializer

        public AbstractTypeMaterializer​(ClassLoader parentClassLoader)
        Parameters:
        parentClassLoader - Class loader to use for generated classes; if null, will use class loader that loaded materializer itself.
    • Method Detail

      • 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 interface com.fasterxml.jackson.core.Versioned
      • setDefaultPackage

        public void setDefaultPackage​(String defPkg)
        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 for AbstractTypeResolver that Jackson calls to materialize an abstract type.
        Overrides:
        resolveAbstractType in class com.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

        protected Class<?> _materializeRawType​(com.fasterxml.jackson.databind.cfg.MapperConfig<?> config,
                                               com.fasterxml.jackson.databind.introspect.AnnotatedClass typeDef,
                                               String nameToUse)
      • _loadAndResolve

        protected Class<?> _loadAndResolve​(String className,
                                           byte[] bytecode,
                                           Class<?> rawType)
      • _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 and java.util: 2.13 and later simply block all types in java.*.

        Parameters:
        type - Type that we are asked to materialize
        Returns:
        True if materialization should proceed; false if not.