public static void doWithFields(Class<?> clazz,FieldCallback fc,FieldFilter ff){
  Class<?> targetClass=clazz;
  do {
    Field[] fields=targetClass.getDeclaredFields();
    for (    Field field : fields) {
      if (ff != null && !ff.matches(field)) {
        continue;
      }
      try {
        fc.doWith(field);
      }
 catch (      IllegalAccessException ex) {
        throw new IllegalStateException("Not allowed to access field '" + field.getName() + "': "+ ex);
      }
    }
    targetClass=targetClass.getSuperclass();
  }
 while (targetClass != null && targetClass != Object.class);
}

public static void doWithFields ( Class < ? > clazz , FieldCallback fc , FieldFilter ff ) { Class < ? > targetClass = clazz ; do { Field [ ] fields = targetClass . getDeclaredFields ( ) ; for ( Field field : fields ) { if ( ff != null && ! ff . matches ( field ) ) { continue ; } try { fc . doWith ( field ) ; } catch ( IllegalAccessException ex ) { throw new IllegalStateException ( "Not allowed to access field '" + field . getName ( ) + "': " + ex ) ; } } targetClass = targetClass . getSuperclass ( ) ; } while ( targetClass != null && targetClass != Object . class ) ; }
invoke the given callback on all fields in the target class , going up the class hierarchy to get all declared fields .
