static ArrayList<Field> allFields(final Class<?> clazz){
  final ArrayList<Field> res=new ArrayList<>();
  Class<?> cl=clazz;
  while (cl != null) {
    final Field[] fields=cl.getDeclaredFields();
    Collections.addAll(res,fields);
    cl=cl.getSuperclass();
  }
  return res;
}

static ArrayList < Field > allFields ( final Class < ? > clazz ) { final ArrayList < Field > res = new ArrayList < > ( ) ; Class < ? > cl = clazz ; while ( cl != null ) { final Field [ ] fields = cl . getDeclaredFields ( ) ; Collections . addAll ( res , fields ) ; cl = cl . getSuperclass ( ) ; } return res ; }
get all the fields in this class and its super - classes .
