org.easymock.classextension.internal
Class ReflectionUtils

java.lang.Object
  extended by org.easymock.classextension.internal.ReflectionUtils

public final class ReflectionUtils
extends Object


Method Summary
static Method findMethod(Class<?> clazz, String name)
          Attempt to find a Method on the supplied class with the supplied name and no parameters.
static Method findMethod(Class<?> clazz, String name, Class<?>... paramTypes)
          Attempt to find a Method on the supplied class with the supplied name and parameter types.
static
<T> Constructor<T>
getConstructor(Class<T> clazz, Object... objs)
          Returns a constructor that contains objs as arguments.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

findMethod

public static Method findMethod(Class<?> clazz,
                                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 Method findMethod(Class<?> clazz,
                                String name,
                                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> Constructor<T> getConstructor(Class<T> clazz,
                                                Object... objs)
                                     throws 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.

Parameters:
objs - list of arguments of the constructor
Returns:
a constructor with the arguments in objs
Throws:
NoSuchMethodException - when the constructor with args does not exist or is ambiguous


Copyright © 2003-2011 OFFIS, Henri Tremblay. All Rights Reserved.