code: public static List<Field> getAllFields(Class<?> cls) {
          final List<Field> allFields = new ArrayList<Field>();
          Class<?> currentClass = cls;
          while (currentClass != null) {
              final Field[] declaredFields = currentClass.getDeclaredFields();
              Collections.addAll(allFields, declaredFields);
              currentClass = currentClass.getSuperclass();
          }
          return allFields;
      }
docs: Gets all fields of the given class and its parents (if any).
  
  @param cls the {@link Class} to query
  @return an array of Fields (possibly empty).