|
Watchmaker Framework API (Version 0.6.2) |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.uncommons.util.reflection.ReflectionUtils
public final class ReflectionUtils
Helper methods to simplify code that uses reflection. These methods handle the checked exceptions and throw only unchecked exceptions. They are useful for dealing with reflection when we know that there is no chance of a checked exception. We can use this class and avoid all of the boiler-plate exception handling.
| Method Summary | ||
|---|---|---|
static
|
findKnownConstructor(Class<T> aClass,
Class<?>... paramTypes)
Looks up a constructor that is explicitly identified. |
|
static Method |
findKnownMethod(Class<?> aClass,
String name,
Class<?>... paramTypes)
Looks up a method that is explicitly identified. |
|
static
|
invokeUnchecked(Constructor<T> constructor,
Object... arguments)
Invokes the specified constructor without throwing any checked exceptions. |
|
static
|
invokeUnchecked(Method method,
Object target,
Object... arguments)
Invokes the specified method without throwing any checked exceptions. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static <T> T invokeUnchecked(Method method,
Object target,
Object... arguments)
T - The return type of the method. The compiler can usually infer the
correct type.method - The method to invoke. Both the method and its class must have
been declared public and non-abstract, otherwise they will be inaccessible.target - The object on which to invoke the method.arguments - The method arguments.
public static <T> T invokeUnchecked(Constructor<T> constructor,
Object... arguments)
T - The return type of the method. The compiler can usually infer the
correct type.constructor - The constructor to invoke. Both the constructor and its
class must have been declared public, and the class must not be abstract,
otherwise they will be inaccessible.arguments - The method arguments.
public static Method findKnownMethod(Class<?> aClass,
String name,
Class<?>... paramTypes)
aClass - The class in which the method exists.name - The name of the method.paramTypes - The types of the method's parameters.
public static <T> Constructor<T> findKnownConstructor(Class<T> aClass,
Class<?>... paramTypes)
T - The type of object that the constructor creates.aClass - The class in which the constructor exists.paramTypes - The types of the constructor's parameters.
|
Watchmaker Framework API (Version 0.6.2) |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||