public static Set < Field > getFields ( Class < ? > clazz , Filter < Field > filter ) { Set < Field > fields = new HashSet < Field > ( ) ; Class < ? > cursor = clazz ; while ( cursor != null && cursor != Object . class ) { // get all fields and apply filters fields . addAll ( Filter . apply ( filter , cursor . getDeclaredFields ( ) ) ) ; // up one step on the hierarchy cursor = cursor . getSuperclass ( ) ; } return fields ; }
Returns the filtered set of fields of the given class including those inherited from the super - classes ; if provided complex filter criteria can be applied .