Package com.aspectran.core.util
Class BeanDescriptor
- java.lang.Object
-
- com.aspectran.core.util.BeanDescriptor
-
public class BeanDescriptor extends java.lang.ObjectThis class represents a cached set of bean property information that allows for easy mapping between property names and getter/setter methods.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static intclearCache()Clear the ClassDescriptor cache.java.lang.String[]getDistinctMethodNames()Gets the class methods' names that is unique.java.lang.reflect.MethodgetGetter(java.lang.String name)Gets the getter for a property as a Method object.java.lang.Class<?>getGetterType(java.lang.String name)Gets the type for a property getter.static BeanDescriptorgetInstance(java.lang.Class<?> type)Gets an instance of ClassDescriptor for the specified class.java.lang.String[]getReadablePropertyNames()Gets an array of the readable properties for an object.java.lang.String[]getReadablePropertyNamesWithoutNonSerializable()java.lang.reflect.MethodgetSetter(java.lang.String name)Gets the setter for a property as a Method object.<T extends java.lang.annotation.Annotation>
TgetSetterAnnotation(java.lang.reflect.Method method, java.lang.Class<T> annotationType)Invokes the annotation of the given type.<T extends java.lang.annotation.Annotation>
TgetSetterAnnotation(java.lang.String name, java.lang.Class<T> annotationType)Invokes the annotation of the given type.java.lang.Class<?>getSetterType(java.lang.String name)Gets the type for a property setter.java.lang.String[]getWritablePropertyNames()Gets an array of the writable properties for an object.booleanhasReadableProperty(java.lang.String propertyName)Check to see if a class has a readable property by name.booleanhasWritableProperty(java.lang.String propertyName)Check to see if a class has a writable property by name.
-
-
-
Method Detail
-
getGetter
public java.lang.reflect.Method getGetter(java.lang.String name) throws java.lang.NoSuchMethodExceptionGets the getter for a property as a Method object.- Parameters:
name- the name of the property- Returns:
- the getter Method
- Throws:
java.lang.NoSuchMethodException- when a getter method cannot be found
-
getSetter
public java.lang.reflect.Method getSetter(java.lang.String name) throws java.lang.NoSuchMethodExceptionGets the setter for a property as a Method object.- Parameters:
name- the name of the property- Returns:
- the setter method
- Throws:
java.lang.NoSuchMethodException- when a setter method cannot be found
-
getGetterType
public java.lang.Class<?> getGetterType(java.lang.String name) throws java.lang.NoSuchMethodExceptionGets the type for a property getter.- Parameters:
name- the name of the property- Returns:
- the Class of the property getter
- Throws:
java.lang.NoSuchMethodException- when a getter method cannot be found
-
getSetterType
public java.lang.Class<?> getSetterType(java.lang.String name) throws java.lang.NoSuchMethodExceptionGets the type for a property setter.- Parameters:
name- the name of the property- Returns:
- the Class of the property setter
- Throws:
java.lang.NoSuchMethodException- when a setter method cannot be found
-
getSetterAnnotation
public <T extends java.lang.annotation.Annotation> T getSetterAnnotation(java.lang.String name, java.lang.Class<T> annotationType) throws java.lang.NoSuchMethodExceptionInvokes 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:
java.lang.NoSuchMethodException- when a setter method cannot be found
-
getSetterAnnotation
public <T extends java.lang.annotation.Annotation> T getSetterAnnotation(java.lang.reflect.Method method, java.lang.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
public java.lang.String[] getReadablePropertyNames()
Gets an array of the readable properties for an object.- Returns:
- the array
-
getReadablePropertyNamesWithoutNonSerializable
public java.lang.String[] getReadablePropertyNamesWithoutNonSerializable()
-
getWritablePropertyNames
public java.lang.String[] getWritablePropertyNames()
Gets an array of the writable properties for an object.- Returns:
- the array
-
hasWritableProperty
public boolean hasWritableProperty(java.lang.String propertyName)
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
public boolean hasReadableProperty(java.lang.String propertyName)
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
public java.lang.String[] getDistinctMethodNames()
Gets the class methods' names that is unique.- Returns:
- the distinct method names
-
getInstance
public static BeanDescriptor getInstance(java.lang.Class<?> type)
Gets an instance of ClassDescriptor for the specified class.- Parameters:
type- the class for which to lookup 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
-
-