Class BeanDescriptor

java.lang.Object
com.aspectran.utils.BeanDescriptor

public class BeanDescriptor extends Object
This class represents a cached set of bean property information that allows for easy mapping between property names and getter/setter methods.
  • Method Details

    • getGetter

      public Method getGetter(String name) throws NoSuchMethodException
      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

      public Method getSetter(String name) throws NoSuchMethodException
      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

      public Class<?> getGetterType(String name) throws NoSuchMethodException
      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

      public Class<?> getSetterType(String name) throws NoSuchMethodException
      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 name
      annotationType - 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 method
      annotationType - the annotation type to look for
      Returns:
      the annotation object, or null if not found
    • getReadablePropertyNames

      public String[] getReadablePropertyNames()
      Gets an array of the readable properties for an object.
      Returns:
      the array
    • getReadablePropertyNamesWithoutNonSerializable

      public String[] getReadablePropertyNamesWithoutNonSerializable()
    • getWritablePropertyNames

      public String[] getWritablePropertyNames()
      Gets an array of the writable properties for an object.
      Returns:
      the array
    • hasWritableProperty

      public boolean hasWritableProperty(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(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 String[] getDistinctMethodNames()
      Gets the class methods' names that is unique.
      Returns:
      the distinct method names
    • getInstance

      public static BeanDescriptor getInstance(Class<?> type)
      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