Class BeanBuilder

java.lang.Object
com.fasterxml.jackson.module.mrbean.BeanBuilder

public class BeanBuilder extends Object
Heavy lifter of mr Bean package: class that keeps track of logical POJO properties, and figures out how to create an implementation class.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
    protected final com.fasterxml.jackson.databind.JavaType
    Abstract class or interface that the bean is created to extend or implement.
    protected final com.fasterxml.jackson.databind.introspect.AnnotatedClass
     
    protected final com.fasterxml.jackson.databind.type.TypeFactory
     
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    BeanBuilder(com.fasterxml.jackson.databind.JavaType type, com.fasterxml.jackson.databind.introspect.AnnotatedClass ac, com.fasterxml.jackson.databind.type.TypeFactory tf)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    addGetter(com.fasterxml.jackson.databind.introspect.TypeResolutionContext ctxt, Method m)
     
    protected void
    addSetter(com.fasterxml.jackson.databind.introspect.TypeResolutionContext ctxt, Method m)
     
    byte[]
    build(String className)
    Method that generates byte code for class that implements abstract types requested so far.
    protected String
     
    protected String
     
    protected com.fasterxml.jackson.databind.introspect.TypeResolutionContext
    buildTypeContext(com.fasterxml.jackson.databind.JavaType ctxtType)
     
    protected String
    cap(String prefix, String name)
     
    construct(com.fasterxml.jackson.databind.cfg.MapperConfig<?> config, com.fasterxml.jackson.databind.JavaType type, com.fasterxml.jackson.databind.introspect.AnnotatedClass ac)
     
    protected void
    createField(org.objectweb.asm.ClassWriter cw, POJOProperty prop, com.fasterxml.jackson.module.mrbean.BeanBuilder.TypeDescription type)
     
    protected void
    createGetter(org.objectweb.asm.ClassWriter cw, String internalClassName, POJOProperty prop, com.fasterxml.jackson.module.mrbean.BeanBuilder.TypeDescription propertyType)
     
    protected void
    createSetter(org.objectweb.asm.ClassWriter cw, String internalClassName, POJOProperty prop, com.fasterxml.jackson.module.mrbean.BeanBuilder.TypeDescription propertyType)
     
    protected void
    createUnimplementedMethod(org.objectweb.asm.ClassWriter cw, String internalClassName, Method method)
    Builder for methods that just throw an exception, basically "unsupported operation" implementation.
    protected String
    decap(String name)
     
    protected POJOProperty
    findProperty(com.fasterxml.jackson.databind.introspect.TypeResolutionContext ctxt, String propName)
     
    protected static void
    generateDefaultConstructor(org.objectweb.asm.ClassWriter cw, String superName)
    NOTE: only static because it is needed from TypeDetector
    protected String
     
    protected String
    getPropertyName(String methodName)
     
    protected boolean
    hasConcreteOverride(Method m0, com.fasterxml.jackson.databind.JavaType implementedType)
    Helper method used to detect if an abstract method found in a base class may actually be implemented in a (more) concrete sub-class.
    implement(boolean failOnUnrecognized)
     
    protected static final boolean
     

    Methods inherited from class java.lang.Object

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

    • _beanProperties

      protected Map<String,POJOProperty> _beanProperties
    • _unsupportedMethods

      protected LinkedHashMap<String,Method> _unsupportedMethods
    • _type

      protected final com.fasterxml.jackson.databind.JavaType _type
      Abstract class or interface that the bean is created to extend or implement.
    • _typeDefinition

      protected final com.fasterxml.jackson.databind.introspect.AnnotatedClass _typeDefinition
    • _typeFactory

      protected final com.fasterxml.jackson.databind.type.TypeFactory _typeFactory
  • Constructor Details

    • BeanBuilder

      public BeanBuilder(com.fasterxml.jackson.databind.JavaType type, com.fasterxml.jackson.databind.introspect.AnnotatedClass ac, com.fasterxml.jackson.databind.type.TypeFactory tf)
  • Method Details

    • construct

      public static BeanBuilder construct(com.fasterxml.jackson.databind.cfg.MapperConfig<?> config, com.fasterxml.jackson.databind.JavaType type, com.fasterxml.jackson.databind.introspect.AnnotatedClass ac)
    • implement

      public BeanBuilder implement(boolean failOnUnrecognized)
      Parameters:
      failOnUnrecognized - If true, and an unrecognized (non-getter, non-setter) method is encountered, will throw IllegalArgumentException; if false, will implement bogus method that will throw UnsupportedOperationException if called.
    • build

      public byte[] build(String className)
      Method that generates byte code for class that implements abstract types requested so far.
      Parameters:
      className - Fully-qualified name of the class to generate
      Returns:
      Byte code Class instance built by this builder
    • hasConcreteOverride

      protected boolean hasConcreteOverride(Method m0, com.fasterxml.jackson.databind.JavaType implementedType)
      Helper method used to detect if an abstract method found in a base class may actually be implemented in a (more) concrete sub-class.
      Since:
      2.4
    • getPropertyName

      protected String getPropertyName(String methodName)
    • buildGetterName

      protected String buildGetterName(String fieldName)
    • buildSetterName

      protected String buildSetterName(String fieldName)
    • getInternalClassName

      protected String getInternalClassName(String className)
    • addGetter

      protected void addGetter(com.fasterxml.jackson.databind.introspect.TypeResolutionContext ctxt, Method m)
    • addSetter

      protected void addSetter(com.fasterxml.jackson.databind.introspect.TypeResolutionContext ctxt, Method m)
    • findProperty

      protected POJOProperty findProperty(com.fasterxml.jackson.databind.introspect.TypeResolutionContext ctxt, String propName)
    • returnsBoolean

      protected static final boolean returnsBoolean(Method m)
    • generateDefaultConstructor

      protected static void generateDefaultConstructor(org.objectweb.asm.ClassWriter cw, String superName)
      NOTE: only static because it is needed from TypeDetector
    • createField

      protected void createField(org.objectweb.asm.ClassWriter cw, POJOProperty prop, com.fasterxml.jackson.module.mrbean.BeanBuilder.TypeDescription type)
    • createSetter

      protected void createSetter(org.objectweb.asm.ClassWriter cw, String internalClassName, POJOProperty prop, com.fasterxml.jackson.module.mrbean.BeanBuilder.TypeDescription propertyType)
    • createGetter

      protected void createGetter(org.objectweb.asm.ClassWriter cw, String internalClassName, POJOProperty prop, com.fasterxml.jackson.module.mrbean.BeanBuilder.TypeDescription propertyType)
    • createUnimplementedMethod

      protected void createUnimplementedMethod(org.objectweb.asm.ClassWriter cw, String internalClassName, Method method)
      Builder for methods that just throw an exception, basically "unsupported operation" implementation.
    • decap

      protected String decap(String name)
    • cap

      protected String cap(String prefix, String name)
    • buildTypeContext

      protected com.fasterxml.jackson.databind.introspect.TypeResolutionContext buildTypeContext(com.fasterxml.jackson.databind.JavaType ctxtType)