code: public static List<Field> getDeclaredFields(@NonNull Class<?> clazz, boolean recursive) {
        List<Field> fields = new ArrayList<>();
        do {
           fields.addAll(Arrays.asList(clazz.getDeclaredFields()));
           clazz = clazz.getSuperclass();
        } while (recursive && clazz != null && clazz != Object.class);
        return fields;
     }
docs: Gets declared fields.
  
  @param clazz     the clazz
  @param recursive the recursive
  @return the declared fields