Package com.aspectran.utils
Class BeanDescriptor
java.lang.Object
com.aspectran.utils.BeanDescriptor
This class represents a cached set of bean property information that
allows for easy mapping between property names and getter/setter methods.
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
Clear the ClassDescriptor cache.String[]
Gets the class methods' names that is unique.Gets the getter for a property as a Method object.Class
<?> getGetterType
(String name) Gets the type for a property getter.static BeanDescriptor
getInstance
(Class<?> type) Gets an instance of ClassDescriptor for the specified class.String[]
Gets an array of the readable properties for an object.String[]
Gets the setter for a property as a Method object.<T extends Annotation>
TgetSetterAnnotation
(Method method, Class<T> annotationType) Invokes the annotation of the given type.<T extends Annotation>
TgetSetterAnnotation
(String name, Class<T> annotationType) Invokes the annotation of the given type.Class
<?> getSetterType
(String name) Gets the type for a property setter.String[]
Gets an array of the writable properties for an object.boolean
hasReadableProperty
(String propertyName) Check to see if a class has a readable property by name.boolean
hasWritableProperty
(String propertyName) Check to see if a class has a writable property by name.
-
Method Details
-
getGetter
Gets the getter for a property as a Method object.- Parameters:
name
- the name of the property- Returns:
- the getter Method
- Throws:
NoSuchMethodException
- when a getter method cannot be found
-
getSetter
Gets the setter for a property as a Method object.- Parameters:
name
- the name of the property- Returns:
- the setter method
- Throws:
NoSuchMethodException
- when a setter method cannot be found
-
getGetterType
Gets the type for a property getter.- Parameters:
name
- the name of the property- Returns:
- the Class of the property getter
- Throws:
NoSuchMethodException
- when a getter method cannot be found
-
getSetterType
Gets the type for a property setter.- Parameters:
name
- the name of the property- Returns:
- the Class of the property setter
- Throws:
NoSuchMethodException
- when a setter method cannot be found
-
getSetterAnnotation
public <T extends Annotation> T getSetterAnnotation(String name, Class<T> annotationType) throws NoSuchMethodException Invokes the annotation of the given type.- Type Parameters:
T
- the annotation type- Parameters:
name
- the given setter nameannotationType
- the annotation type to look for- Returns:
- the annotation object, or null if not found
- Throws:
NoSuchMethodException
- when a setter method cannot be found
-
getSetterAnnotation
public <T extends Annotation> T getSetterAnnotation(@NonNull Method method, Class<T> annotationType) Invokes the annotation of the given type.- Type Parameters:
T
- the annotation type- Parameters:
method
- the given setter methodannotationType
- the annotation type to look for- Returns:
- the annotation object, or null if not found
-
getReadablePropertyNames
Gets an array of the readable properties for an object.- Returns:
- the array
-
getReadablePropertyNamesWithoutNonSerializable
-
getWritablePropertyNames
Gets an array of the writable properties for an object.- Returns:
- the array
-
hasWritableProperty
Check to see if a class has a writable property by name.- Parameters:
propertyName
- the name of the property to check- Returns:
- true if the object has a writable property by the name
-
hasReadableProperty
Check to see if a class has a readable property by name.- Parameters:
propertyName
- the name of the property to check- Returns:
- true if the object has a readable property by the name
-
getDistinctMethodNames
Gets the class methods' names that is unique.- Returns:
- the distinct method names
-
getInstance
Gets an instance of ClassDescriptor for the specified class.- Parameters:
type
- the class for which to look up the method cache- Returns:
- the method cache for the class
-
clearCache
public static int clearCache()Clear the ClassDescriptor cache.- Returns:
- the number of cached ClassDescriptor cleared
-