Class BasicBeanDescription
- java.lang.Object
-
- com.fasterxml.jackson.databind.BeanDescription
-
- com.fasterxml.jackson.databind.introspect.BasicBeanDescription
-
public class BasicBeanDescription extends BeanDescription
DefaultBeanDescription
implementation used by Jackson.Although sub-classing is a theoretical possibility there are no known use cases for that, nor is such usage tested or supported. Separation from API is mostly to isolate some implementation details here and keep API simple.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description LinkedHashMap<String,AnnotatedField>
_findPropertyFields(Collection<String> ignoredProperties, boolean forSerialization)
Deprecated.Since 2.7.2, does not seem to be used?boolean
addProperty(BeanPropertyDefinition def)
TypeBindings
bindingsForBeanType()
Deprecated.AnnotatedMember
findAnyGetter()
Method used to locate the method of introspected class that implementsJsonAnyGetter
.AnnotatedMember
findAnySetterAccessor()
Method used to locate a mutator (settable field, or 2-argument set method) of introspected class that implementsJsonAnySetter
.Map<String,AnnotatedMember>
findBackReferenceProperties()
Deprecated.List<BeanPropertyDefinition>
findBackReferences()
Method for locating all back-reference properties (setters, fields) bean hasString
findClassDescription()
Accessor for possible description for the bean type, used for constructing documentation.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.Class<?>[]
findDefaultViews()
Method for finding out if the POJO specifies default view(s) to use for properties, considering both per-type annotations and global default settings.Converter<Object,Object>
findDeserializationConverter()
Method for findingConverter
used for serializing instances of this class.JsonFormat.Value
findExpectedFormat(JsonFormat.Value defValue)
Method for checking what is the expected format for POJO, as defined by defaults and possible annotations.Method
findFactoryMethod(Class<?>... expArgTypes)
Deprecated.Map<Object,AnnotatedMember>
findInjectables()
AnnotatedMember
findJsonKeyAccessor()
Method for locating accessor (readable field, or "getter" method) that hasJsonKey
annotation, if any.AnnotatedMember
findJsonValueAccessor()
Method for locating accessor (readable field, or "getter" method) that hasJsonValue
annotation, if any.AnnotatedMethod
findJsonValueMethod()
Deprecated.AnnotatedMethod
findMethod(String name, Class<?>[] paramTypes)
Class<?>
findPOJOBuilder()
Method for checking if the POJO type has annotations to indicate that a builder is to be used for instantiating instances and handling data binding, instead of standard bean deserializer.JsonPOJOBuilder.Value
findPOJOBuilderConfig()
Method for finding configuration for POJO Builder class.List<BeanPropertyDefinition>
findProperties()
BeanPropertyDefinition
findProperty(PropertyName name)
JsonInclude.Value
findPropertyInclusion(JsonInclude.Value defValue)
Method for determining whether null properties should be written out for a Bean of introspected type.Converter<Object,Object>
findSerializationConverter()
Method for findingConverter
used for serializing instances of this class.Constructor<?>
findSingleArgConstructor(Class<?>... argTypes)
Deprecated.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()
Method for accessing low-level information about Class this item describes.List<AnnotatedConstructor>
getConstructors()
Helper method that will return all non-default constructors (that is, constructors that take one or more arguments) this class has.List<AnnotatedAndMetadata<AnnotatedConstructor,JsonCreator.Mode>>
getConstructorsWithMode()
Method similar toBeanDescription.getConstructors()
except will also introspectJsonCreator.Mode
and filter out ones marked as not applicable and include mode (or lack thereof) for remaining constructors.List<AnnotatedMethod>
getFactoryMethods()
Helper method that will check all static methods of the bean class that seem like factory methods eligible to be used as Creators.List<AnnotatedAndMetadata<AnnotatedMethod,JsonCreator.Mode>>
getFactoryMethodsWithMode()
Method similar toBeanDescription.getFactoryMethods()
but will returnJsonCreator.Mode
metadata along with qualifying factory method candidates.Set<String>
getIgnoredPropertyNames()
ObjectIdInfo
getObjectIdInfo()
Accessor for getting information about Object Id expected to be used for this POJO type, if any.boolean
hasKnownClassAnnotations()
Method for checking whether class being described has any annotations recognized by registered annotation introspector.boolean
hasProperty(PropertyName name)
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".boolean
removeProperty(String propName)
Method that can be used to prune unwanted properties, during construction of serializers and deserializers.JavaType
resolveType(Type jdkType)
Deprecated.-
Methods inherited from class com.fasterxml.jackson.databind.BeanDescription
findAnySetter, findAnySetterField, getBeanClass, getType, isNonStaticInnerClass
-
-
-
-
Method Detail
-
forDeserialization
public static BasicBeanDescription forDeserialization(POJOPropertiesCollector coll)
Factory method to use for constructing an instance to use for building deserializers.
-
forSerialization
public static BasicBeanDescription forSerialization(POJOPropertiesCollector coll)
Factory method to use for constructing an instance to use for building serializers.
-
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.
-
removeProperty
public boolean removeProperty(String propName)
Method that can be used to prune unwanted properties, during construction of serializers and deserializers. Use with utmost care, if at all...- Since:
- 2.1
-
addProperty
public boolean addProperty(BeanPropertyDefinition def)
-
hasProperty
public boolean hasProperty(PropertyName name)
- Since:
- 2.6
-
findProperty
public BeanPropertyDefinition findProperty(PropertyName name)
- Since:
- 2.6
-
getClassInfo
public AnnotatedClass getClassInfo()
Description copied from class:BeanDescription
Method for accessing low-level information about Class this item describes.- Specified by:
getClassInfo
in classBeanDescription
-
getObjectIdInfo
public ObjectIdInfo getObjectIdInfo()
Description copied from class:BeanDescription
Accessor for getting information about Object Id expected to be used for this POJO type, if any.- Specified by:
getObjectIdInfo
in classBeanDescription
-
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.
-
findJsonKeyAccessor
public AnnotatedMember findJsonKeyAccessor()
Description copied from class:BeanDescription
Method for locating accessor (readable field, or "getter" method) that hasJsonKey
annotation, if any. If multiple ones are found, an error is reported by throwingIllegalArgumentException
- Overrides:
findJsonKeyAccessor
in classBeanDescription
-
findJsonValueMethod
@Deprecated public AnnotatedMethod findJsonValueMethod()
Deprecated.- Specified by:
findJsonValueMethod
in classBeanDescription
-
findJsonValueAccessor
public AnnotatedMember findJsonValueAccessor()
Description copied from class:BeanDescription
Method for locating accessor (readable field, or "getter" method) that hasJsonValue
annotation, if any. If multiple ones are found, an error is reported by throwingIllegalArgumentException
- Specified by:
findJsonValueAccessor
in classBeanDescription
-
getIgnoredPropertyNames
public Set<String> getIgnoredPropertyNames()
- Specified by:
getIgnoredPropertyNames
in classBeanDescription
-
hasKnownClassAnnotations
public boolean hasKnownClassAnnotations()
Description copied from class:BeanDescription
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
@Deprecated public TypeBindings bindingsForBeanType()
Deprecated.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
@Deprecated public JavaType resolveType(Type jdkType)
Deprecated.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()
Description copied from class:BeanDescription
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
-
findAnySetterAccessor
public AnnotatedMember findAnySetterAccessor() throws IllegalArgumentException
Description copied from class:BeanDescription
Method used to locate a mutator (settable field, or 2-argument set method) of introspected class that implementsJsonAnySetter
. If no such mutator 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:
findAnySetterAccessor
in classBeanDescription
- Throws:
IllegalArgumentException
-
findInjectables
public Map<Object,AnnotatedMember> findInjectables()
- Specified by:
findInjectables
in classBeanDescription
-
getConstructors
public List<AnnotatedConstructor> getConstructors()
Description copied from class:BeanDescription
Helper method that will return all non-default constructors (that is, constructors that take one or more arguments) this class has.- Specified by:
getConstructors
in classBeanDescription
-
getConstructorsWithMode
public List<AnnotatedAndMetadata<AnnotatedConstructor,JsonCreator.Mode>> getConstructorsWithMode()
Description copied from class:BeanDescription
Method similar toBeanDescription.getConstructors()
except will also introspectJsonCreator.Mode
and filter out ones marked as not applicable and include mode (or lack thereof) for remaining constructors.Note that no other filtering (regarding visibility or other annotations) is performed
- Specified by:
getConstructorsWithMode
in classBeanDescription
-
instantiateBean
public Object instantiateBean(boolean fixAccess)
Description copied from class:BeanDescription
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".- Specified by:
instantiateBean
in classBeanDescription
- 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.
-
findMethod
public AnnotatedMethod findMethod(String name, Class<?>[] paramTypes)
- Specified by:
findMethod
in classBeanDescription
-
findExpectedFormat
public JsonFormat.Value findExpectedFormat(JsonFormat.Value defValue)
Description copied from class:BeanDescription
Method for checking what is the expected format for POJO, as defined by defaults and possible annotations. Note that this may be further refined by per-property annotations.- Specified by:
findExpectedFormat
in classBeanDescription
-
findDefaultViews
public Class<?>[] findDefaultViews()
Description copied from class:BeanDescription
Method for finding out if the POJO specifies default view(s) to use for properties, considering both per-type annotations and global default settings.- Specified by:
findDefaultViews
in classBeanDescription
-
findSerializationConverter
public Converter<Object,Object> findSerializationConverter()
Description copied from class:BeanDescription
Method for findingConverter
used for serializing instances of this class.- Specified by:
findSerializationConverter
in classBeanDescription
-
findPropertyInclusion
public JsonInclude.Value findPropertyInclusion(JsonInclude.Value 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).- Specified by:
findPropertyInclusion
in classBeanDescription
-
findAnyGetter
public AnnotatedMember 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
-
findBackReferences
public List<BeanPropertyDefinition> findBackReferences()
Description copied from class:BeanDescription
Method for locating all back-reference properties (setters, fields) bean has- Specified by:
findBackReferences
in classBeanDescription
-
findBackReferenceProperties
@Deprecated public Map<String,AnnotatedMember> findBackReferenceProperties()
Deprecated.Description copied from class:BeanDescription
Method for locating all back-reference properties (setters, fields) bean has- Specified by:
findBackReferenceProperties
in classBeanDescription
-
getFactoryMethods
public List<AnnotatedMethod> getFactoryMethods()
Description copied from class:BeanDescription
Helper method that will check all static methods of the bean class that seem like factory methods eligible to be used as Creators. This requires that the static method:- Returns type compatible with bean type (same or subtype)
- Is recognized from either explicit annotation (usually
@JsonCreator
OR naming: namesvalueOf()
andfromString()
are recognized but only for 1-argument factory methods, and in case offromString()
argument type must further be eitherString
orCharSequence
.
- Specified by:
getFactoryMethods
in classBeanDescription
- Returns:
- List of static methods considered as possible Factory methods
-
getFactoryMethodsWithMode
public List<AnnotatedAndMetadata<AnnotatedMethod,JsonCreator.Mode>> getFactoryMethodsWithMode()
Description copied from class:BeanDescription
Method similar toBeanDescription.getFactoryMethods()
but will returnJsonCreator.Mode
metadata along with qualifying factory method candidates.- Specified by:
getFactoryMethodsWithMode
in classBeanDescription
-
findSingleArgConstructor
@Deprecated public Constructor<?> findSingleArgConstructor(Class<?>... argTypes)
Deprecated.- Specified by:
findSingleArgConstructor
in classBeanDescription
-
findFactoryMethod
@Deprecated public Method findFactoryMethod(Class<?>... expArgTypes)
Deprecated.- Specified by:
findFactoryMethod
in classBeanDescription
-
findPOJOBuilder
public Class<?> findPOJOBuilder()
Description copied from class:BeanDescription
Method for checking if the POJO type has annotations to indicate that a builder is to be used for instantiating instances and handling data binding, instead of standard bean deserializer.- Specified by:
findPOJOBuilder
in classBeanDescription
-
findPOJOBuilderConfig
public JsonPOJOBuilder.Value findPOJOBuilderConfig()
Description copied from class:BeanDescription
Method for finding configuration for POJO Builder class.- Specified by:
findPOJOBuilderConfig
in classBeanDescription
-
findDeserializationConverter
public Converter<Object,Object> findDeserializationConverter()
Description copied from class:BeanDescription
Method for findingConverter
used for serializing instances of this class.- Specified by:
findDeserializationConverter
in classBeanDescription
-
findClassDescription
public String findClassDescription()
Description copied from class:BeanDescription
Accessor for possible description for the bean type, used for constructing documentation.- Overrides:
findClassDescription
in classBeanDescription
-
_findPropertyFields
@Deprecated public LinkedHashMap<String,AnnotatedField> _findPropertyFields(Collection<String> ignoredProperties, boolean forSerialization)
Deprecated.Since 2.7.2, does not seem to be used?- 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.
-
-