Top Description Inners Fields Constructors Methods
com.fasterxml.jackson.module.mrbean

public Class BeanBuilder

extends Object
Class Inheritance
Imports
java.lang.reflect.Method, .Modifier, java.util.ArrayList, .LinkedHashMap, .Map, com.fasterxml.jackson.databind.JavaType, com.fasterxml.jackson.databind.cfg.MapperConfig, com.fasterxml.jackson.databind.introspect.AnnotatedClass, .TypeResolutionContext, com.fasterxml.jackson.databind.type.TypeFactory, org.objectweb.asm.ClassWriter, .FieldVisitor, .MethodVisitor, .Type

Heavy lifter of mr Bean package: class that keeps track of logical POJO properties, and figures out how to create an implementation class.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
BeanBuilder.TypeDescription

Helper bean used to encapsulate most details of type handling

Field Summary

Modifier and TypeField and Description
protected Map<String, POJOProperty>
protected final JavaType
_type

Abstract class or interface that the bean is created to extend or implement.

protected final AnnotatedClass
protected final TypeFactory
protected LinkedHashMap<String, Method>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
protected void
public byte[]

Returns:

Byte code Class instance built by this builder
build
(String
Fully-qualified name of the class to generate
className
)

Method that generates byte code for class that implements abstract types requested so far.

protected String
protected String
protected TypeResolutionContext
protected String
cap(String prefix, String name)

public static BeanBuilder
protected void
protected void
createGetter(ClassWriter cw, String internalClassName, POJOProperty prop, BeanBuilder.TypeDescription propertyType)

protected void
createSetter(ClassWriter cw, String internalClassName, POJOProperty prop, BeanBuilder.TypeDescription propertyType)

protected void
createUnimplementedMethod(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
protected static void
generateDefaultConstructor(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, 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.

public BeanBuilder
implement(boolean
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.
failOnUnrecognized
)

protected static final boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_beanPropertiesback to summary
protected Map<String, POJOProperty> _beanProperties
_typeback to summary
protected final JavaType _type

Abstract class or interface that the bean is created to extend or implement.

_typeDefinitionback to summary
protected final AnnotatedClass _typeDefinition
_typeFactoryback to summary
protected final TypeFactory _typeFactory
_unsupportedMethodsback to summary
protected LinkedHashMap<String, Method> _unsupportedMethods

Constructor Detail

BeanBuilderback to summary
public BeanBuilder(JavaType type, AnnotatedClass ac, TypeFactory tf)

Method Detail

addGetterback to summary
protected void addGetter(TypeResolutionContext ctxt, Method m)
addSetterback to summary
protected void addSetter(TypeResolutionContext ctxt, Method m)
buildback to summary
public byte[] build(String className)

Method that generates byte code for class that implements abstract types requested so far.

Parameters
className:String

Fully-qualified name of the class to generate

Returns:byte[]

Byte code Class instance built by this builder

buildGetterNameback to summary
protected String buildGetterName(String fieldName)
buildSetterNameback to summary
protected String buildSetterName(String fieldName)
buildTypeContextback to summary
protected TypeResolutionContext buildTypeContext(JavaType ctxtType)
capback to summary
protected String cap(String prefix, String name)
constructback to summary
public static BeanBuilder construct(MapperConfig<?> config, JavaType type, AnnotatedClass ac)
createFieldback to summary
protected void createField(ClassWriter cw, POJOProperty prop, BeanBuilder.TypeDescription type)
createGetterback to summary
protected void createGetter(ClassWriter cw, String internalClassName, POJOProperty prop, BeanBuilder.TypeDescription propertyType)
createSetterback to summary
protected void createSetter(ClassWriter cw, String internalClassName, POJOProperty prop, BeanBuilder.TypeDescription propertyType)
createUnimplementedMethodback to summary
protected void createUnimplementedMethod(ClassWriter cw, String internalClassName, Method method)

Builder for methods that just throw an exception, basically "unsupported operation" implementation.

decapback to summary
protected String decap(String name)
findPropertyback to summary
protected POJOProperty findProperty(TypeResolutionContext ctxt, String propName)
generateDefaultConstructorback to summary
protected static void generateDefaultConstructor(ClassWriter cw, String superName)

Note

only static because it is needed from TypeDetector

getInternalClassNameback to summary
protected String getInternalClassName(String className)
getPropertyNameback to summary
protected String getPropertyName(String methodName)
hasConcreteOverrideback to summary
protected boolean hasConcreteOverride(Method m0, 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
implementback to summary
public BeanBuilder implement(boolean failOnUnrecognized)
Parameters
failOnUnrecognized:boolean

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.

returnsBooleanback to summary
protected static final boolean returnsBoolean(Method m)
com.fasterxml.jackson.module.mrbean back to summary

pack-priv Class BeanBuilder.TypeDescription

extends Object
Class Inheritance
  • java.lang.Object
  • com.fasterxml.jackson.module.mrbean.BeanBuilder.TypeDescription

Helper bean used to encapsulate most details of type handling

Field Summary

Modifier and TypeField and Description
private final Type
private JavaType

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
public String
public int
public Class<?>
public int
public boolean

Returns:

True if type has direct generic declaration (which may need to be copied)
hasGenerics
()

public static BeanBuilder.TypeDescription
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

_asmTypeback to summary
private final Type _asmType
_jacksonTypeback to summary
private JavaType _jacksonType

Constructor Detail

TypeDescriptionback to summary
public TypeDescription(JavaType type)

Method Detail

erasedSignatureback to summary
public String erasedSignature()
genericSignatureback to summary
public String genericSignature()
getLoadOpcodeback to summary
public int getLoadOpcode()
getRawClassback to summary
public Class<?> getRawClass()
getReturnOpcodeback to summary
public int getReturnOpcode()
hasGenericsback to summary
public boolean hasGenerics()
Returns:boolean

True if type has direct generic declaration (which may need to be copied)

moreSpecificTypeback to summary
public static BeanBuilder.TypeDescription moreSpecificType(BeanBuilder.TypeDescription desc1, BeanBuilder.TypeDescription desc2)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override