Package info.u_team.u_team_core.util
Class ReflectionUtil
java.lang.Object
info.u_team.u_team_core.util.ReflectionUtil
Utility methods for reflection stuff
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <O,
N> void Utility method to copy a field value from an old oject instance to a new instance.static Field
Method to find a field in a give class.static <I,
V> V Gets the value of a field.static <I,
V> void Sets the value of a field.
-
Constructor Details
-
ReflectionUtil
public ReflectionUtil()
-
-
Method Details
-
findField
Method to find a field in a give class. The name will be mapped to the right mappings. Will return the field with widened access.- Parameters:
clazz
- Class of the fieldfield
- The name of the field- Returns:
- The field
-
setValue
Sets the value of a field. Catches exceptions and throws a runtime exception.- Parameters:
field
- The fieldinstance
- The object instance. Null for static fieldsvalue
- The value
-
getValue
Gets the value of a field. Catches exceptions and throws a runtime exception.- Parameters:
field
- The fieldinstance
- The object instance. Null for static fields- Returns:
- The value
-
copyValue
Utility method to copy a field value from an old oject instance to a new instance. Catches exceptions and throws a runtime exception.- Parameters:
field
- The fieldoldInstance
- Old objectnewInstance
- New object
-