public final class ReflectionUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static <T> T |
get(java.lang.Object instance,
java.lang.reflect.Field field)
Gets the value of a field.
|
static <T> T |
getUnchecked(java.lang.Object instance,
java.lang.reflect.Field field)
Gets the value of a field.
|
static <T> T |
invoke(java.lang.Object instance,
java.lang.reflect.Method method,
java.lang.Object... args)
Gets the output of a method.
|
static <T> T |
invokeUnchecked(java.lang.Object instance,
java.lang.reflect.Method method,
java.lang.Object... args)
Gets the output value of a method.
|
public static <T> T get(java.lang.Object instance, java.lang.reflect.Field field) throws java.lang.ReflectiveOperationException
T
- the type of object in the fieldinstance
- the instance of the class to get the field's value fromfield
- the field to get the value ofjava.lang.ReflectiveOperationException
- if the value of the field could not be retrievedpublic static <T> T getUnchecked(java.lang.Object instance, java.lang.reflect.Field field)
T
- the type of object in the fieldinstance
- the instance of the class to get the field's value fromfield
- the field to get the value ofjava.lang.RuntimeException
- if a reflective exception was thrown while attempting to get the value of the fieldpublic static <T> T invoke(java.lang.Object instance, java.lang.reflect.Method method, java.lang.Object... args) throws java.lang.ReflectiveOperationException
T
- the return type of the methodinstance
- te instance of the class to call the method onmethod
- the method to callargs
- the arguments to the methodjava.lang.ReflectiveOperationException
- if the method could not be calledpublic static <T> T invokeUnchecked(java.lang.Object instance, java.lang.reflect.Method method, java.lang.Object... args)
T
- the return type of the methodinstance
- the instance of the class to call the method onmethod
- the method to callargs
- the arguments to the methodjava.lang.RuntimeException
- if a reflective exception was thrown while attempting to call the method