Class DefaultIntrospectionContext
java.lang.Object
org.apache.commons.beanutils.DefaultIntrospectionContext
- All Implemented Interfaces:
IntrospectionContext
An implementation of the IntrospectionContext interface used by
PropertyUtilsBean when doing introspection of a bean class.
This class implements the methods required by the
IntrospectionContext interface in a straight-forward manner
based on a map. It is used internally only. It is not thread-safe.
- Since:
- 1.9
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Class<?> The current class for introspection.private final Map<String, PropertyDescriptor> A map for storing the already added property descriptors.private static final PropertyDescriptor[]Constant for an empty array of property descriptors. -
Constructor Summary
ConstructorsConstructorDescriptionDefaultIntrospectionContext(Class<?> cls) Creates a new instance ofDefaultIntrospectionContextand sets the current class for introspection. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the given property descriptor to this context.voidaddPropertyDescriptors(PropertyDescriptor[] descs) Adds an array of property descriptors to this context.getPropertyDescriptor(String name) Returns the descriptor for the property with the given name or null if this property is unknown.Returns an array with all descriptors added to this context.Class<?> Returns the class that is subject of introspection.booleanhasProperty(String name) Tests whether a descriptor for the property with the given name is already contained in this context.Returns a set with the names of all properties known to this context.voidRemoves the descriptor for the property with the given name.
-
Field Details
-
EMPTY_DESCRIPTORS
Constant for an empty array of property descriptors. -
currentClass
The current class for introspection. -
descriptors
A map for storing the already added property descriptors.
-
-
Constructor Details
-
DefaultIntrospectionContext
Creates a new instance ofDefaultIntrospectionContextand sets the current class for introspection.- Parameters:
cls- the current class
-
-
Method Details
-
addPropertyDescriptor
Description copied from interface:IntrospectionContextAdds the given property descriptor to this context. This method is called by aBeanIntrospectorduring introspection for each detected property. If this context already contains a descriptor for the affected property, it is overridden.- Specified by:
addPropertyDescriptorin interfaceIntrospectionContext- Parameters:
desc- the property descriptor
-
addPropertyDescriptors
Description copied from interface:IntrospectionContextAdds an array of property descriptors to this context. Using this method multiple descriptors can be added at once.- Specified by:
addPropertyDescriptorsin interfaceIntrospectionContext- Parameters:
descs- the array of descriptors to be added
-
getPropertyDescriptor
Description copied from interface:IntrospectionContextReturns the descriptor for the property with the given name or null if this property is unknown.- Specified by:
getPropertyDescriptorin interfaceIntrospectionContext- Parameters:
name- the name of the property in question- Returns:
- the descriptor for this property or null if this property is unknown
-
getPropertyDescriptors
Returns an array with all descriptors added to this context. This method is used to obtain the results of introspection.- Returns:
- an array with all known property descriptors
-
getTargetClass
Description copied from interface:IntrospectionContextReturns the class that is subject of introspection.- Specified by:
getTargetClassin interfaceIntrospectionContext- Returns:
- the current class
-
hasProperty
Description copied from interface:IntrospectionContextTests whether a descriptor for the property with the given name is already contained in this context. This method can be used for instance to prevent that an already existing property descriptor is overridden.- Specified by:
hasPropertyin interfaceIntrospectionContext- Parameters:
name- the name of the property in question- Returns:
- true if a descriptor for this property has already been added, false otherwise
-
propertyNames
Description copied from interface:IntrospectionContextReturns a set with the names of all properties known to this context.- Specified by:
propertyNamesin interfaceIntrospectionContext- Returns:
- a set with the known property names
-
removePropertyDescriptor
Description copied from interface:IntrospectionContextRemoves the descriptor for the property with the given name.- Specified by:
removePropertyDescriptorin interfaceIntrospectionContext- Parameters:
name- the name of the affected property
-