Class Inspector

java.lang.Object
groovy.inspect.Inspector

public class Inspector
extends Object
The Inspector provides a unified access to an object's information that can be determined by introspection.
  • Field Details

  • Constructor Details

    • Inspector

      public Inspector​(Object objectUnderInspection)
      Parameters:
      objectUnderInspection - must not be null
  • Method Details

    • getClassProps

      public String[] getClassProps()
      Get the Class Properties of the object under inspection.
      Returns:
      String array to be indexed by the CLASS_xxx_IDX constants
    • isGroovy

      public boolean isGroovy()
    • getObject

      public Object getObject()
      Gets the object being inspected.
      Returns:
      the object
    • getMethods

      public Object[] getMethods()
      Get info about usual Java instance and class Methods as well as Constructors.
      Returns:
      Array of StringArrays that can be indexed with the MEMBER_xxx_IDX constants
    • getMetaMethods

      public Object[] getMetaMethods()
      Get info about instance and class Methods that are dynamically added through Groovy.
      Returns:
      Array of StringArrays that can be indexed with the MEMBER_xxx_IDX constants
    • getPublicFields

      public Object[] getPublicFields()
      Get info about usual Java public fields incl. constants.
      Returns:
      Array of StringArrays that can be indexed with the MEMBER_xxx_IDX constants
    • getPublicFieldsWithInfo

      public Object[] getPublicFieldsWithInfo()
    • getPropertyInfo

      public Object[] getPropertyInfo()
      Get info about Properties (Java and Groovy alike).
      Returns:
      Array of StringArrays that can be indexed with the MEMBER_xxx_IDX constants
    • fieldInfo

      protected String[] fieldInfo​(Field field)
    • fieldWithInfo

      protected Tuple2<Object,​String[]> fieldWithInfo​(Field field)
    • fieldInfo

      protected String[] fieldInfo​(PropertyValue pv)
    • fieldWithInfo

      protected Tuple2<Object,​String[]> fieldWithInfo​(PropertyValue pv)
    • getPropertiesWithInfo

      public Object[] getPropertiesWithInfo()
    • getClassUnderInspection

      protected Class getClassUnderInspection()
    • shortName

      public static String shortName​(Class clazz)
    • methodInfo

      protected String[] methodInfo​(Method method)
    • methodInfo

      protected String[] methodInfo​(Constructor ctor)
    • methodInfo

      protected String[] methodInfo​(MetaMethod method)
    • withoutNulls

      protected String[] withoutNulls​(String[] toNormalize)
    • print

      public static void print​(Object[] memberInfo)
    • sort

      public static Collection sort​(List<Object> memberInfo)
    • sort

      public static Collection sort​(List<Object> memberInfo, Comparator<Object> comparator)