Class ReflectionUtil
java.lang.Object
nl.pim16aap2.testing.reflection.ReflectionUtil
Utility class for reflection.
-
Method Summary
Modifier and TypeMethodDescriptionstatic FieldGets a named field from a class.static FieldGets a named field from an object.static MethodGets a named method from a class.static MethodGets a named method from an object.static voidSets the value of a field in an object.static voidSets the value of a field in an object.
-
Method Details
-
setField
Sets the value of a field in an object.- Parameters:
obj- The object to set the field in.fieldName- The name of the field to set.value- The value to set the field to.- Throws:
RuntimeException- If the field could not be found or accessed.
-
setField
Sets the value of a field in an object.- Parameters:
source- The class to get the field from.obj- The object to set the field in. This should be an instance ofsourceor a subclass of it.fieldName- The name of the field to set.value- The value to set the field to.- Throws:
RuntimeException- If the field could not be found or accessed.
-
getField
-
getField
-
getMethod
-
getMethod
-