Class FieldUtils
java.lang.Object
com.creativityfactory.swiftserver.utils.FieldUtils
This class provides utility methods for working with fields using reflection.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetAllFields
(Class<?> clazz) Returns all the fields of a class including the inherited ones using reflection.static Object
updateFields
(Object oldObj, Object newObj) Updates the fields of an old object with the fields of a new object of the same class.
-
Constructor Details
-
FieldUtils
public FieldUtils()
-
-
Method Details
-
getAllFields
Returns all the fields of a class including the inherited ones using reflection.- Parameters:
clazz
- The class to retrieve fields from.- Returns:
- A List of Field objects representing all the fields of the given class.
-
updateFields
Updates the fields of an old object with the fields of a new object of the same class.- Parameters:
oldObj
- the old object to updatenewObj
- the new object containing the updated field values- Returns:
- the updated old object or null if the classes of the old and new objects do not match
-