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

Author:
tatu, sunny
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Enumeration that defines togglable features that guide the serialization feature.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final com.fasterxml.jackson.module.mrbean.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!)
    protected String
    Package name to use as prefix for generated classes.
    protected int
    Bit set that contains all enabled features
    protected 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
    Constructor
    Description
     
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected 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 not
    materializeGenericType(com.fasterxml.jackson.databind.cfg.MapperConfig<?> config, com.fasterxml.jackson.databind.JavaType type)
     
    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 for AbstractTypeResolver that Jackson calls to materialize an abstract type.
    void
    Method for enabling or disabling specified feature.
    void
    Method for specifying package to use for generated classes.
    com.fasterxml.jackson.core.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

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • 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:
    • _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 Details

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

      public final boolean isEnabled(AbstractTypeMaterializer.Feature f)
      Method for checking whether given feature is enabled or not
    • enable

      public void enable(AbstractTypeMaterializer.Feature f)
      Method for enabling specified feature.
    • disable

      public void disable(AbstractTypeMaterializer.Feature f)
      Method for disabling specified feature.
    • set

      public void set(AbstractTypeMaterializer.Feature f, boolean state)
      Method for enabling or disabling specified feature.
    • 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.