ReflectionUtils
Date: 2015-09-17

org.easymock.internal

## Class ReflectionUtils

- java.lang.Object
- - org.easymock.internal.ReflectionUtils

-     public final class ReflectionUtils
      extends java.lang.Object

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.reflect.Method` | `OBJECT_EQUALS`
    `static java.lang.reflect.Method` | `OBJECT_FINALIZE`
    `static java.lang.reflect.Method` | `OBJECT_HASHCODE`
    `static java.lang.reflect.Method` | `OBJECT_TOSTRING`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.lang.reflect.Method` | `findMethod(java.lang.Class<?> clazz, java.lang.String name)` Attempt to find a `Method` on the supplied class with the supplied name and no parameters.
    `static java.lang.reflect.Method` | `findMethod(java.lang.Class<?> clazz, java.lang.String name, java.lang.Class<?>... paramTypes)` Attempt to find a `Method` on the supplied class with the supplied name and parameter types.
    `static <T> java.lang.reflect.Constructor<T>` | `getConstructor(java.lang.Class<T> clazz, java.lang.Object... objs)` Returns a constructor that contains `objs` as arguments.
    `static java.lang.reflect.Method` | `getDeclaredMethod(java.lang.Class<?> clazz, java.lang.String name, java.lang.Class<?>... paramTypes)` Basically calls getDeclaredMethod on a Class but wraps the NoSuchMethodException into a Runtime.

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

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

- - ### Field Detail

    - #### OBJECT_EQUALS

          public static final java.lang.reflect.Method OBJECT_EQUALS

    - #### OBJECT_HASHCODE

          public static final java.lang.reflect.Method OBJECT_HASHCODE

    - #### OBJECT_TOSTRING

          public static final java.lang.reflect.Method OBJECT_TOSTRING

    - #### OBJECT_FINALIZE

          public static final java.lang.reflect.Method OBJECT_FINALIZE

  - ### Method Detail

    - #### findMethod

          public static java.lang.reflect.Method findMethod(java.lang.Class<?> clazz,
                                            java.lang.String name)

      Attempt to find a `Method` on the supplied class with the supplied name and no parameters. Searches all superclasses up to `Object`.

      Returns `null` if no `Method` can be found.

      Parameters:
        `clazz` - the class to introspect
        `name` - the name of the method
      Returns:
        the Method object, or `null` if none found

    - #### findMethod

          public static java.lang.reflect.Method findMethod(java.lang.Class<?> clazz,
                                            java.lang.String name,
                                            java.lang.Class<?>... paramTypes)

      Attempt to find a `Method` on the supplied class with the supplied name and parameter types. Searches all superclasses up to `Object`.

      Returns `null` if no `Method` can be found.

      Parameters:
        `clazz` - the class to introspect
        `name` - the name of the method
        `paramTypes` - the parameter types of the method (may be `null` to indicate any signature)
      Returns:
        the Method object, or `null` if none found

    - #### getConstructor

          public static <T> java.lang.reflect.Constructor<T> getConstructor(java.lang.Class<T> clazz,
                                                            java.lang.Object... objs)
                                                                 throws java.lang.NoSuchMethodException

      Returns a constructor that contains `objs` as arguments.

      We could not do something like `clazz.getConstructor(objs.class())` because that would require casting all the passed arguments to the exact parameter types of the desired constructor.

      Type Parameters:
        `T` - type of the class searched
      Parameters:
        `clazz` - class on which we are searching the constructor
        `objs` - list of arguments of the constructor
      Returns:
        a constructor with the arguments in `objs`
      Throws:
        `java.lang.NoSuchMethodException` - when the constructor with `args` does not exist or is ambiguous

    - #### getDeclaredMethod

          public static java.lang.reflect.Method getDeclaredMethod(java.lang.Class<?> clazz,
                                                   java.lang.String name,
                                                   java.lang.Class<?>... paramTypes)

      Basically calls getDeclaredMethod on a Class but wraps the NoSuchMethodException into a Runtime.
      Parameters:
        `clazz` - class on which the getDeclaredMethod is called
        `name` - method name
        `paramTypes` - method parameters
      Returns:
        the method searched