Package: groovy.inspect

## [Java] Class Inspector

- 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.

- - ### Nested Class Summary

    Nested classes
    Modifiers | Name | Description
    --- | --- | ---
    `static class` | `Inspector.MemberComparator` | Comparator for member information arrays.
    `static class` | `Inspector.MemberComparatorWithValue` | Comparator for property tuples that include values.

  - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static int` | `CLASS_CLASS_IDX` | Index for class information.
    `static int` | `CLASS_INTERFACE_IDX` | Index for implemented interface information.
    `static int` | `CLASS_OTHER_IDX` | Index for other class information.
    `static int` | `CLASS_PACKAGE_IDX` | Index for package information.
    `static int` | `CLASS_SUPERCLASS_IDX` | Index for superclass information.
    `static String` | `GROOVY` | Origin label for Groovy members.
    `static String` | `JAVA` | Origin label for Java members.
    `static int` | `MEMBER_DECLARER_IDX` | Index for member declarer information.
    `static int` | `MEMBER_EXCEPTIONS_IDX` | Index for member exception information.
    `static int` | `MEMBER_MODIFIER_IDX` | Index for member modifier information.
    `static int` | `MEMBER_NAME_IDX` | Index for member name information.
    `static int` | `MEMBER_ORIGIN_IDX` | Index for member origin information.
    `static int` | `MEMBER_PARAMS_IDX` | Index for member parameter information.
    `static int` | `MEMBER_TYPE_IDX` | Index for member type information.
    `static int` | `MEMBER_VALUE_IDX` | Index for member value information.
    `static String` | `NOT_APPLICABLE` | Placeholder for unavailable information.
    `protected Object` | `objectUnderInspection` | Object currently being inspected.

  - ### Constructor Summary

    Constructors
    Constructor and description
    `Inspector(Object objectUnderInspection)` Parameters: `objectUnderInspection` - must not be null

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `protected String[]` | `fieldInfo(Field field)` Builds descriptive information for a Java field.
    `` | `protected String[]` | `fieldInfo(PropertyValue pv)` Builds descriptive information for a Groovy property value.
    `` | `protected Tuple2<Object, String>` | `fieldWithInfo(PropertyValue pv)` Builds the value and metadata tuple for a Groovy property.
    `` | `public String[]` | `getClassProps()` Get the Class Properties of the object under inspection.
    `` | `protected Class` | `getClassUnderInspection()` Gets the class of the inspected object.
    `` | `public Object[]` | `getMetaMethods()` Get info about instance and class Methods that are dynamically added through Groovy.
    `` | `public Tuple2[]` | `getMetaMethodsWithInfo()` Get info about instance and class Methods that are dynamically added through Groovy.
    `` | `public Object[]` | `getMethods()` Get info about usual Java instance and class Methods as well as Constructors.
    `` | `public Tuple2[]` | `getMethodsWithInfo()` Get info about usual Java instance and class Methods as well as Constructors.
    `` | `public Object` | `getObject()` Gets the object being inspected.
    `` | `public Object[]` | `getPropertiesWithInfo()` Gets properties together with their values and formatted metadata.
    `` | `public Object[]` | `getPropertyInfo()` Get info about Properties (Java and Groovy alike).
    `` | `public Object[]` | `getPublicFields()` Get info about usual Java public fields incl. constants.
    `` | `public boolean` | `isGroovy()` Indicates whether the inspected type implements GroovyObject.
    `` | `protected String[]` | `methodInfo(Method method)` Builds descriptive information for a Java method.
    `` | `protected String[]` | `methodInfo(Constructor ctor)` Builds descriptive information for a constructor.
    `` | `protected String[]` | `methodInfo(MetaMethod method)` Builds descriptive information for a Groovy meta-method.
    `` | `public static void` | `print(Object[] memberInfo)` Prints member information to System.out.
    `` | `public static String` | `shortName(Class clazz)` Returns the class name without its package prefix.
    `` | `public static Collection` | `sort(List<Object> memberInfo)` Sorts member information using the default comparator.
    `` | `public static Collection` | `sort(List<Object> memberInfo, Comparator<Object> comparator)` Sorts member information using the supplied comparator.
    `` | `protected String[]` | `withoutNulls(String[] toNormalize)` Replaces `null` entries with NOT_APPLICABLE.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### public static final int CLASS_CLASS_IDX

      Index for class information.

    - #### public static final int CLASS_INTERFACE_IDX

      Index for implemented interface information.

    - #### public static final int CLASS_OTHER_IDX

      Index for other class information.

    - #### public static final int CLASS_PACKAGE_IDX

      Index for package information.

    - #### public static final int CLASS_SUPERCLASS_IDX

      Index for superclass information.

    - #### public static final String GROOVY

      Origin label for Groovy members.

    - #### public static final String JAVA

      Origin label for Java members.

    - #### public static final int MEMBER_DECLARER_IDX

      Index for member declarer information.

    - #### public static final int MEMBER_EXCEPTIONS_IDX

      Index for member exception information.

    - #### public static final int MEMBER_MODIFIER_IDX

      Index for member modifier information.

    - #### public static final int MEMBER_NAME_IDX

      Index for member name information.

    - #### public static final int MEMBER_ORIGIN_IDX

      Index for member origin information.

    - #### public static final int MEMBER_PARAMS_IDX

      Index for member parameter information.

    - #### public static final int MEMBER_TYPE_IDX

      Index for member type information.

    - #### public static final int MEMBER_VALUE_IDX

      Index for member value information.

    - #### public static final String NOT_APPLICABLE

      Placeholder for unavailable information.

    - #### protected Object objectUnderInspection

      Object currently being inspected.

  - ### Constructor Detail

    - #### public Inspector(Object objectUnderInspection)

      Parameters:
        `objectUnderInspection` - must not be null

  - ### Method Detail

    - #### protected String[] fieldInfo(Field field)

      Builds descriptive information for a Java field.

      Parameters:
        `field` - the field to describe
      Returns:
        the field information array

    - #### protected String[] fieldInfo(PropertyValue pv)

      Builds descriptive information for a Groovy property value.

      Parameters:
        `pv` - the property value to describe
      Returns:
        the property information array

    - #### protected Tuple2<Object, String> fieldWithInfo(PropertyValue pv)

      Builds the value and metadata tuple for a Groovy property.

      Parameters:
        `pv` - the property value to describe
      Returns:
        the property tuple

    - #### public String[] getClassProps()

      Get the Class Properties of the object under inspection.

      Returns:
        String array to be indexed by the CLASS_xxx_IDX constants

    - #### protected Class getClassUnderInspection()

      Gets the class of the inspected object.

      Returns:
        the inspected class

    - #### 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

    - #### public Tuple2[] getMetaMethodsWithInfo()

      Get info about instance and class Methods that are dynamically added through Groovy.

    - #### 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

    - #### public Tuple2[] getMethodsWithInfo()

      Get info about usual Java instance and class Methods as well as Constructors.

    - #### public Object getObject()

      Gets the object being inspected.

      Returns:
        the object

    - #### public Object[] getPropertiesWithInfo()

      Gets properties together with their values and formatted metadata.

      Returns:
        the property/value tuples

    - #### 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

    - #### 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

    - #### public boolean isGroovy()

      Indicates whether the inspected type implements GroovyObject.

      Returns:
        `true` if the inspected type is Groovy-aware

    - #### protected String[] methodInfo(Method method)

      Builds descriptive information for a Java method.

      Parameters:
        `method` - the method to describe
      Returns:
        the method information array

    - #### protected String[] methodInfo(Constructor ctor)

      Builds descriptive information for a constructor.

      Parameters:
        `ctor` - the constructor to describe
      Returns:
        the constructor information array

    - #### protected String[] methodInfo(MetaMethod method)

      Builds descriptive information for a Groovy meta-method.

      Parameters:
        `method` - the meta-method to describe
      Returns:
        the method information array

    - #### public static void print(Object[] memberInfo)

      Prints member information to System.out.

      Parameters:
        `memberInfo` - the member information to print

    - #### public static String shortName(Class clazz)

      Returns the class name without its package prefix.

      Parameters:
        `clazz` - the class to shorten
      Returns:
        the shortened class name, or NOT_APPLICABLE

    - #### public static Collection sort(List<Object> memberInfo)

      Sorts member information using the default comparator.

      Parameters:
        `memberInfo` - the member information to sort
      Returns:
        the sorted collection

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

      Sorts member information using the supplied comparator.

      Parameters:
        `memberInfo` - the member information to sort
        `comparator` - the comparator to apply
      Returns:
        the sorted collection

    - #### protected String[] withoutNulls(String[] toNormalize)

      Replaces `null` entries with NOT_APPLICABLE.

      Parameters:
        `toNormalize` - the array to normalize
      Returns:
        the normalized array