Class BasicBeanDescription
- java.lang.Object
-
- org.codehaus.jackson.map.BeanDescription
-
- org.codehaus.jackson.map.introspect.BasicBeanDescription
-
public class BasicBeanDescription extends BeanDescription
DefaultBeanDescription
implementation. Can theoretically be subclassed to customize some aspects of property introspection.
-
-
Field Summary
Fields Modifier and Type Field Description protected AnnotationIntrospector
_annotationIntrospector
protected AnnotatedMethod
_anyGetterMethod
protected AnnotatedMethod
_anySetterMethod
protected TypeBindings
_bindings
We may need type bindings for the bean type.protected AnnotatedClass
_classInfo
Information collected about the class introspected.protected MapperConfig<?>
_config
protected Set<String>
_ignoredPropertyNames
Set of properties that can be ignored during deserialization, due to being marked as ignored.protected Set<String>
_ignoredPropertyNamesForDeser
protected Map<Object,AnnotatedMember>
_injectables
protected AnnotatedMethod
_jsonValueMethod
protected List<BeanPropertyDefinition>
_properties
Properties collected for the POJO.-
Fields inherited from class org.codehaus.jackson.map.BeanDescription
_type
-
-
Constructor Summary
Constructors Modifier Constructor Description BasicBeanDescription(MapperConfig<?> config, JavaType type, AnnotatedClass ac)
Deprecated.Since 1.9, should use factory methods insteadprotected
BasicBeanDescription(MapperConfig<?> config, JavaType type, AnnotatedClass ac, List<BeanPropertyDefinition> properties)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description LinkedHashMap<String,AnnotatedField>
_findPropertyFields(Collection<String> ignoredProperties, boolean forSerialization)
TypeBindings
bindingsForBeanType()
Accessor for type bindings that may be needed to fully resolve types of member object, such as return and argument types of methods and constructors, and types of fields.AnnotatedMethod
findAnyGetter()
Method used to locate the method of introspected class that implementsJsonAnyGetter
.AnnotatedMethod
findAnySetter()
Method used to locate the method of introspected class that implementsJsonAnySetter
.Map<String,AnnotatedMember>
findBackReferenceProperties()
Method for locating all back-reference properties (setters, fields) bean hasList<String>
findCreatorPropertyNames()
Method for getting ordered list of named Creator properties.AnnotatedConstructor
findDefaultConstructor()
Method that will locate the no-arg constructor for this class, if it has one, and that constructor has not been marked as ignorable.LinkedHashMap<String,AnnotatedField>
findDeserializableFields(VisibilityChecker<?> visibilityChecker, Collection<String> ignoredProperties)
Method
findFactoryMethod(Class<?>... expArgTypes)
Method that can be called to find if introspected class declares a static "valueOf" factory method that returns an instance of introspected type, given one of acceptable types.LinkedHashMap<String,AnnotatedMethod>
findGetters(VisibilityChecker<?> visibilityChecker, Collection<String> ignoredProperties)
Map<Object,AnnotatedMember>
findInjectables()
AnnotatedMethod
findJsonValueMethod()
Method for locating the getter method that is annotated withJsonValue
annotation, if any.AnnotatedMethod
findMethod(String name, Class<?>[] paramTypes)
List<BeanPropertyDefinition>
findProperties()
LinkedHashMap<String,AnnotatedField>
findSerializableFields(VisibilityChecker<?> visibilityChecker, Collection<String> ignoredProperties)
JsonSerialize.Inclusion
findSerializationInclusion(JsonSerialize.Inclusion defValue)
Method for determining whether null properties should be written out for a Bean of introspected type.LinkedHashMap<String,AnnotatedMethod>
findSetters(VisibilityChecker<?> visibilityChecker)
Constructor<?>
findSingleArgConstructor(Class<?>... argTypes)
Method that can be called to locate a single-arg constructor that takes specified exact type (will not accept supertype constructors)static BasicBeanDescription
forDeserialization(POJOPropertiesCollector coll)
Factory method to use for constructing an instance to use for building deserializers.static BasicBeanDescription
forOtherUse(MapperConfig<?> config, JavaType type, AnnotatedClass ac)
Factory method to use for constructing an instance to use for purposes other than building serializers or deserializers; will only have information on class, not on properties.static BasicBeanDescription
forSerialization(POJOPropertiesCollector coll)
Factory method to use for constructing an instance to use for building serializers.Annotations
getClassAnnotations()
Method for accessing collection of annotations the bean class has.AnnotatedClass
getClassInfo()
List<AnnotatedConstructor>
getConstructors()
List<AnnotatedMethod>
getFactoryMethods()
Set<String>
getIgnoredPropertyNames()
Set<String>
getIgnoredPropertyNamesForDeser()
boolean
hasKnownClassAnnotations()
Method for checking whether class being described has any annotations recognized by registered annotation introspector.Object
instantiateBean(boolean fixAccess)
Method called to create a "default instance" of the bean, currently only needed for obtaining default field values which may be used for suppressing serialization of fields that have "not changed".protected boolean
isFactoryMethod(AnnotatedMethod am)
JavaType
resolveType(Type jdkType)
Method for resolving given JDK type, using this bean as the generic type resolution context.-
Methods inherited from class org.codehaus.jackson.map.BeanDescription
getBeanClass, getType
-
-
-
-
Field Detail
-
_config
protected final MapperConfig<?> _config
-
_annotationIntrospector
protected final AnnotationIntrospector _annotationIntrospector
-
_classInfo
protected final AnnotatedClass _classInfo
Information collected about the class introspected.
-
_bindings
protected TypeBindings _bindings
We may need type bindings for the bean type. If so, we'll construct it lazily
-
_properties
protected final List<BeanPropertyDefinition> _properties
Properties collected for the POJO.
-
_anySetterMethod
protected AnnotatedMethod _anySetterMethod
-
_injectables
protected Map<Object,AnnotatedMember> _injectables
-
_ignoredPropertyNames
protected Set<String> _ignoredPropertyNames
Set of properties that can be ignored during deserialization, due to being marked as ignored.
-
_jsonValueMethod
protected AnnotatedMethod _jsonValueMethod
-
_anyGetterMethod
protected AnnotatedMethod _anyGetterMethod
-
-
Constructor Detail
-
BasicBeanDescription
@Deprecated public BasicBeanDescription(MapperConfig<?> config, JavaType type, AnnotatedClass ac)
Deprecated.Since 1.9, should use factory methods instead
-
BasicBeanDescription
protected BasicBeanDescription(MapperConfig<?> config, JavaType type, AnnotatedClass ac, List<BeanPropertyDefinition> properties)
- Since:
- 1.9
-
-
Method Detail
-
forDeserialization
public static BasicBeanDescription forDeserialization(POJOPropertiesCollector coll)
Factory method to use for constructing an instance to use for building deserializers.- Since:
- 1.9
-
forSerialization
public static BasicBeanDescription forSerialization(POJOPropertiesCollector coll)
Factory method to use for constructing an instance to use for building serializers.- Since:
- 1.9
-
forOtherUse
public static BasicBeanDescription forOtherUse(MapperConfig<?> config, JavaType type, AnnotatedClass ac)
Factory method to use for constructing an instance to use for purposes other than building serializers or deserializers; will only have information on class, not on properties.- Since:
- 1.9
-
getClassInfo
public AnnotatedClass getClassInfo()
- Specified by:
getClassInfo
in classBeanDescription
- Since:
- 1.9
-
findProperties
public List<BeanPropertyDefinition> findProperties()
- Specified by:
findProperties
in classBeanDescription
- Returns:
- Ordered Map with logical property name as key, and matching getter method as value.
-
findJsonValueMethod
public AnnotatedMethod findJsonValueMethod()
Method for locating the getter method that is annotated withJsonValue
annotation, if any. If multiple ones are found, an error is reported by throwingIllegalArgumentException
- Specified by:
findJsonValueMethod
in classBeanDescription
-
getIgnoredPropertyNames
public Set<String> getIgnoredPropertyNames()
- Specified by:
getIgnoredPropertyNames
in classBeanDescription
-
hasKnownClassAnnotations
public boolean hasKnownClassAnnotations()
Method for checking whether class being described has any annotations recognized by registered annotation introspector.- Specified by:
hasKnownClassAnnotations
in classBeanDescription
-
getClassAnnotations
public Annotations getClassAnnotations()
Description copied from class:BeanDescription
Method for accessing collection of annotations the bean class has.- Specified by:
getClassAnnotations
in classBeanDescription
-
bindingsForBeanType
public TypeBindings bindingsForBeanType()
Description copied from class:BeanDescription
Accessor for type bindings that may be needed to fully resolve types of member object, such as return and argument types of methods and constructors, and types of fields.- Specified by:
bindingsForBeanType
in classBeanDescription
-
resolveType
public JavaType resolveType(Type jdkType)
Description copied from class:BeanDescription
Method for resolving given JDK type, using this bean as the generic type resolution context.- Specified by:
resolveType
in classBeanDescription
-
findDefaultConstructor
public AnnotatedConstructor findDefaultConstructor()
Method that will locate the no-arg constructor for this class, if it has one, and that constructor has not been marked as ignorable.- Specified by:
findDefaultConstructor
in classBeanDescription
- Since:
- 1.9
-
findAnySetter
public AnnotatedMethod findAnySetter() throws IllegalArgumentException
Method used to locate the method of introspected class that implementsJsonAnySetter
. If no such method exists null is returned. If more than one are found, an exception is thrown. Additional checks are also made to see that method signature is acceptable: needs to take 2 arguments, first one String or Object; second any can be any type.- Specified by:
findAnySetter
in classBeanDescription
- Throws:
IllegalArgumentException
-
findInjectables
public Map<Object,AnnotatedMember> findInjectables()
- Specified by:
findInjectables
in classBeanDescription
-
getConstructors
public List<AnnotatedConstructor> getConstructors()
-
findMethod
public AnnotatedMethod findMethod(String name, Class<?>[] paramTypes)
-
instantiateBean
public Object instantiateBean(boolean fixAccess)
Method called to create a "default instance" of the bean, currently only needed for obtaining default field values which may be used for suppressing serialization of fields that have "not changed".- Parameters:
fixAccess
- If true, method is allowed to fix access to the default constructor (to be able to call non-public constructor); if false, has to use constructor as is.- Returns:
- Instance of class represented by this descriptor, if suitable default constructor was found; null otherwise.
-
getFactoryMethods
public List<AnnotatedMethod> getFactoryMethods()
-
findSingleArgConstructor
public Constructor<?> findSingleArgConstructor(Class<?>... argTypes)
Method that can be called to locate a single-arg constructor that takes specified exact type (will not accept supertype constructors)- Parameters:
argTypes
- Type(s) of the argument that we are looking for
-
findFactoryMethod
public Method findFactoryMethod(Class<?>... expArgTypes)
Method that can be called to find if introspected class declares a static "valueOf" factory method that returns an instance of introspected type, given one of acceptable types.- Parameters:
expArgTypes
- Types that the matching single argument factory method can take: will also accept super types of these types (ie. arg just has to be assignable from expArgType)
-
isFactoryMethod
protected boolean isFactoryMethod(AnnotatedMethod am)
-
findCreatorPropertyNames
public List<String> findCreatorPropertyNames()
Method for getting ordered list of named Creator properties. Returns an empty list is none found. If multiple Creator methods are defined, order between properties from different methods is undefined; however, properties for each such Creator are ordered properly relative to each other. For the usual case of just a single Creator, named properties are thus properly ordered.
-
findSerializationInclusion
public JsonSerialize.Inclusion findSerializationInclusion(JsonSerialize.Inclusion defValue)
Method for determining whether null properties should be written out for a Bean of introspected type. This is based on global feature (lowest priority, passed as argument) and per-class annotation (highest priority).
-
findAnyGetter
public AnnotatedMethod findAnyGetter() throws IllegalArgumentException
Method used to locate the method of introspected class that implementsJsonAnyGetter
. If no such method exists null is returned. If more than one are found, an exception is thrown.- Specified by:
findAnyGetter
in classBeanDescription
- Throws:
IllegalArgumentException
- Since:
- 1.6
-
findBackReferenceProperties
public Map<String,AnnotatedMember> findBackReferenceProperties()
Method for locating all back-reference properties (setters, fields) bean has- Since:
- 1.6
-
_findPropertyFields
public LinkedHashMap<String,AnnotatedField> _findPropertyFields(Collection<String> ignoredProperties, boolean forSerialization)
- Parameters:
ignoredProperties
- (optional) names of properties to ignore; any fields that would be recognized as one of these properties is ignored.forSerialization
- If true, will collect serializable property fields; if false, deserializable- Returns:
- Ordered Map with logical property name as key, and matching field as value.
-
findGetters
public LinkedHashMap<String,AnnotatedMethod> findGetters(VisibilityChecker<?> visibilityChecker, Collection<String> ignoredProperties)
- Specified by:
findGetters
in classBeanDescription
-
findSetters
public LinkedHashMap<String,AnnotatedMethod> findSetters(VisibilityChecker<?> visibilityChecker)
- Specified by:
findSetters
in classBeanDescription
-
findSerializableFields
public LinkedHashMap<String,AnnotatedField> findSerializableFields(VisibilityChecker<?> visibilityChecker, Collection<String> ignoredProperties)
- Specified by:
findSerializableFields
in classBeanDescription
-
findDeserializableFields
public LinkedHashMap<String,AnnotatedField> findDeserializableFields(VisibilityChecker<?> visibilityChecker, Collection<String> ignoredProperties)
- Specified by:
findDeserializableFields
in classBeanDescription
-
-