public final class ReflectionUtils extends Object
Modifier | Constructor and Description |
---|---|
private |
ReflectionUtils()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
static Class<?> |
classFromType(Type t)
Casts the supplied type to a class.
|
static Object |
getField(Field field,
Object object)
Returns the value of the supplied field on the supplied object.
|
static Object |
invokeGetterMethod(Method method,
Object object)
Invokes the supplied method on the supplied object.
|
static void |
invokeSetterMethod(Method method,
Object object,
Object value)
Invokes the supplied method on the supplied object with the supplied value as a parameter.
|
static void |
setField(Field field,
Object object,
Object value)
Sets the supplied value of the supplied field on the supplied object.
|
public static Class<?> classFromType(Type t)
t
- to castIllegalArgumentException
- if t is not an instance of Classpublic static Object getField(Field field, Object object)
field
- containing the value to returnobject
- that has the fieldIllegalArgumentException
- if the field cannot be retrievedpublic static void setField(Field field, Object object, Object value)
field
- of the object to setobject
- that has the fieldvalue
- to setIllegalArgumentException
- if the field cannot be setpublic static Object invokeGetterMethod(Method method, Object object)
method
- to invokeobject
- that has the methodIllegalArgumentException
- if the method cannot be invokedpublic static void invokeSetterMethod(Method method, Object object, Object value)
method
- to invokeobject
- that has the methodvalue
- to setIllegalArgumentException
- if the method cannot be invokedCopyright © 2003-2019 Virginia Tech. All Rights Reserved.