code: public static Field[] getAllDeclaredFields(Class<?> leafClass) {
  
          Assert.notNull(leafClass, "leafClass");
  
          final List<Field> fields = new ArrayList<Field>(32);
  
          ReflectionUtils.doWithFields(leafClass, new ReflectionUtils.FieldCallback() {
  
              @Override
              public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException {
  
                  fields.add(field);
              }
          });
  
          return fields.toArray(new Field[fields.size()]);
      }
docs: Get all declared fields on the leaf class and all superclasses. Leaf class methods are included first.
  
  @param leafClass
  the leaf class.
  @return all declared fields.
  
  @see ReflectionUtils#getAllDeclaredMethods(Class) since is the same approach as this one.