A Technology Blog About Code Development, Architecture, Operating System, Hardware, Tips and Tutorials for Developers.

Wednesday, October 19, 2016

ReflectionUtils.doWithFields()

6:47:00 PM Posted by Satish No comments
Spring has a nice Utility class ReflectionUtils that does just that: it defines a method to loop over all fields of all super classes with a callback: ReflectionUtils.doWithFields()

Documentation:
Invoke the given callback on all fields in the target class, going up the class hierarchy to get all declared fields.

Parameters:
- clazz - the target class to analyze
- fc - the callback to invoke for each field
- ff - the filter that determines the fields to apply the callback to

Sample Code:


Output:
Found field private int java.util.ArrayList.size in type class java.util.ArrayList

0 comments:

Post a Comment