org.eclipse.net4j.util

## Class ReflectUtil

- java.lang.Object
- - org.eclipse.net4j.util.ReflectUtil

-     public final class ReflectUtil
      extends java.lang.Object

  Various static helper methods for dealing with Java reflection.
  Author:
    Eike Stepper

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `ReflectUtil.ExcludeFromDump` Annotates fields that are to be skipped in `ReflectUtil.collectFields()` and `ReflectUtil.toString()`.
    `static class` | `ReflectUtil.PrimitiveType`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static boolean` | `DUMP_STATICS`
    `static java.lang.Object[]` | `NO_ARGUMENTS`
    `static java.lang.Class<?>[]` | `NO_PARAMETERS`
    `static boolean` | `REMEMBER_IDS`
    `static java.lang.Class<java.lang.Object>` | `ROOT_CLASS`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `collectFields(java.lang.Class<?> c, java.util.List<java.lang.reflect.Field> fields)`
    `static void` | `dump(java.lang.Object object)`
    `static void` | `dump(java.lang.Object object, java.lang.String prefix)`
    `static void` | `dump(java.lang.Object object, java.lang.String prefix, java.io.PrintStream out)`
    `static java.lang.String` | `dumpThread()`
    `static Pair<java.lang.reflect.Field,java.lang.Object>[]` | `dumpToArray(java.lang.Object object)`
    `static java.lang.reflect.Field` | `getAccessibleField(java.lang.Class<?> c, java.lang.String fieldName)`
    `static java.lang.reflect.Field` | `getField(java.lang.Class<?> c, java.lang.String fieldName)`
    `static java.lang.Integer` | `getHashCode(java.lang.Object object)`
    `static java.lang.Long` | `getID(java.lang.Object object)`
    `static java.lang.String` | `getLabel(java.lang.Object object)`
    `static java.lang.reflect.Method` | `getMethod(java.lang.Class<?> c, java.lang.String methodName, java.lang.Class<?>... parameterTypes)`
    `static java.lang.String` | `getPackageName(java.lang.Class<? extends java.lang.Object> c)`
    `static java.lang.String` | `getPackageName(java.lang.String className)`
    `static java.lang.String` | `getSimpleClassName(java.lang.Object object)`
    `static java.lang.String` | `getSimpleClassName(java.lang.String name)`
    `static java.lang.String` | `getSimpleName(java.lang.Class<? extends java.lang.Object> c)`
    `static java.lang.Object` | `getValue(java.lang.reflect.Field field, java.lang.Object target)`
    `static java.lang.Object` | `instantiate(java.util.Map<java.lang.Object,java.lang.Object> properties, java.lang.String namespace, java.lang.String classKey, java.lang.ClassLoader classLoader)`
    `static java.lang.Object` | `invokeMethod(java.lang.reflect.Method method, java.lang.Object target, java.lang.Object... arguments)`
    `static boolean` | `isSetter(java.lang.reflect.Method method)`
    `static boolean` | `isSetterName(java.lang.String name)`
    `static void` | `printStackTrace()` Prints the stack trace of the current thread to `System.err`.
    `static void` | `printStackTrace(java.io.PrintStream out, java.lang.StackTraceElement[] stackTrace)`
    `static void` | `printStackTrace(java.lang.StackTraceElement[] stackTrace)`
    `static void` | `setValue(java.lang.reflect.Field field, java.lang.Object target, java.lang.Object value)`
    `static java.lang.String` | `toString(java.lang.Object object)`
    `static java.lang.String` | `toString(java.lang.Object object, java.lang.String prefix)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### ROOT_CLASS

          public static final java.lang.Class<java.lang.Object> ROOT_CLASS

    - #### NO_PARAMETERS

          public static final java.lang.Class<?>[] NO_PARAMETERS

    - #### NO_ARGUMENTS

          public static final java.lang.Object[] NO_ARGUMENTS

    - #### REMEMBER_IDS

          public static boolean REMEMBER_IDS

      Since:
        3.3

    - #### DUMP_STATICS

          public static boolean DUMP_STATICS

  - ### Method Detail

    - #### getMethod

          public static java.lang.reflect.Method getMethod(java.lang.Class<?> c,
                                                           java.lang.String methodName,
                                                           java.lang.Class<?>... parameterTypes)

    - #### invokeMethod

          public static java.lang.Object invokeMethod(java.lang.reflect.Method method,
                                                      java.lang.Object target,
                                                      java.lang.Object... arguments)

    - #### getField

          public static java.lang.reflect.Field getField(java.lang.Class<?> c,
                                                         java.lang.String fieldName)

    - #### getAccessibleField

          public static java.lang.reflect.Field getAccessibleField(java.lang.Class<?> c,
                                                                   java.lang.String fieldName)

      Since:
        3.8

    - #### collectFields

          public static void collectFields(java.lang.Class<?> c,
                                           java.util.List<java.lang.reflect.Field> fields)

    - #### getValue

          public static java.lang.Object getValue(java.lang.reflect.Field field,
                                                  java.lang.Object target)

    - #### setValue

          public static void setValue(java.lang.reflect.Field field,
                                      java.lang.Object target,
                                      java.lang.Object value)

    - #### dumpThread

          public static java.lang.String dumpThread()

      Since:
        3.8

    - #### printStackTrace

          public static void printStackTrace(java.io.PrintStream out,
                                             java.lang.StackTraceElement[] stackTrace)

    - #### printStackTrace

          public static void printStackTrace(java.lang.StackTraceElement[] stackTrace)

    - #### printStackTrace

          public static void printStackTrace()

      Prints the stack trace of the current thread to `System.err`.
      Since:
        3.4

    - #### getHashCode

          public static java.lang.Integer getHashCode(java.lang.Object object)

    - #### getID

          public static java.lang.Long getID(java.lang.Object object)

    - #### getPackageName

          public static java.lang.String getPackageName(java.lang.Class<? extends java.lang.Object> c)

    - #### getPackageName

          public static java.lang.String getPackageName(java.lang.String className)

    - #### getSimpleName

          public static java.lang.String getSimpleName(java.lang.Class<? extends java.lang.Object> c)

    - #### getSimpleClassName

          public static java.lang.String getSimpleClassName(java.lang.String name)

    - #### getSimpleClassName

          public static java.lang.String getSimpleClassName(java.lang.Object object)

    - #### getLabel

          public static java.lang.String getLabel(java.lang.Object object)

    - #### dump

          public static void dump(java.lang.Object object)

    - #### dump

          public static void dump(java.lang.Object object,
                                  java.lang.String prefix)

    - #### dump

          public static void dump(java.lang.Object object,
                                  java.lang.String prefix,
                                  java.io.PrintStream out)

    - #### dumpToArray

          public static Pair<java.lang.reflect.Field,java.lang.Object>[] dumpToArray(java.lang.Object object)

    - #### instantiate

          public static java.lang.Object instantiate(java.util.Map<java.lang.Object,java.lang.Object> properties,
                                                     java.lang.String namespace,
                                                     java.lang.String classKey,
                                                     java.lang.ClassLoader classLoader)
                                              throws java.lang.ClassNotFoundException,
                                                     java.lang.InstantiationException,
                                                     java.lang.IllegalAccessException,
                                                     java.lang.IllegalArgumentException,
                                                     java.lang.reflect.InvocationTargetException

      Throws:
        `java.lang.ClassNotFoundException`
        `java.lang.InstantiationException`
        `java.lang.IllegalAccessException`
        `java.lang.IllegalArgumentException`
        `java.lang.reflect.InvocationTargetException`

    - #### isSetter

          public static boolean isSetter(java.lang.reflect.Method method)

    - #### isSetterName

          public static boolean isSetterName(java.lang.String name)

    - #### toString

          public static java.lang.String toString(java.lang.Object object)

    - #### toString

          public static java.lang.String toString(java.lang.Object object,
                                                  java.lang.String prefix)

Copyright (c) 2014 Eike Stepper (Berlin, Germany) and others.
All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html