Class Reflector


  • public class Reflector
    extends java.lang.Object
    This class represents a cached set of class definition information that allows for easy mapping between property names and getter/setter methods.
    Author:
    Clinton Begin
    • Constructor Summary

      Constructors 
      Constructor Description
      Reflector​(java.lang.Class<?> clazz)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean canControlMemberAccessible()
      Checks whether can control member accessible.
      java.lang.String findPropertyName​(java.lang.String name)  
      java.lang.reflect.Constructor<?> getDefaultConstructor()  
      java.lang.String[] getGetablePropertyNames()
      Gets an array of the readable properties for an object.
      Invoker getGetInvoker​(java.lang.String propertyName)  
      java.lang.Class<?> getGetterType​(java.lang.String propertyName)
      Gets the type for a property getter.
      java.lang.String[] getSetablePropertyNames()
      Gets an array of the writable properties for an object.
      Invoker getSetInvoker​(java.lang.String propertyName)  
      java.lang.Class<?> getSetterType​(java.lang.String propertyName)
      Gets the type for a property setter.
      java.lang.Class<?> getType()
      Gets the name of the class the instance provides information for.
      boolean hasDefaultConstructor()  
      boolean hasGetter​(java.lang.String propertyName)
      Check to see if a class has a readable property by name.
      boolean hasSetter​(java.lang.String propertyName)
      Check to see if a class has a writable property by name.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Reflector

        public Reflector​(java.lang.Class<?> clazz)
    • Method Detail

      • canControlMemberAccessible

        public static boolean canControlMemberAccessible()
        Checks whether can control member accessible.
        Returns:
        If can control member accessible, it return true
        Since:
        3.5.0
      • getType

        public java.lang.Class<?> getType()
        Gets the name of the class the instance provides information for.
        Returns:
        The class name
      • getDefaultConstructor

        public java.lang.reflect.Constructor<?> getDefaultConstructor()
      • hasDefaultConstructor

        public boolean hasDefaultConstructor()
      • getSetInvoker

        public Invoker getSetInvoker​(java.lang.String propertyName)
      • getGetInvoker

        public Invoker getGetInvoker​(java.lang.String propertyName)
      • getSetterType

        public java.lang.Class<?> getSetterType​(java.lang.String propertyName)
        Gets the type for a property setter.
        Parameters:
        propertyName - - the name of the property
        Returns:
        The Class of the property setter
      • getGetterType

        public java.lang.Class<?> getGetterType​(java.lang.String propertyName)
        Gets the type for a property getter.
        Parameters:
        propertyName - - the name of the property
        Returns:
        The Class of the property getter
      • getGetablePropertyNames

        public java.lang.String[] getGetablePropertyNames()
        Gets an array of the readable properties for an object.
        Returns:
        The array
      • getSetablePropertyNames

        public java.lang.String[] getSetablePropertyNames()
        Gets an array of the writable properties for an object.
        Returns:
        The array
      • hasSetter

        public boolean hasSetter​(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
      • hasGetter

        public boolean hasGetter​(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
      • findPropertyName

        public java.lang.String findPropertyName​(java.lang.String name)