public static List < Field > listFields ( Class < ? > clazz ) { assert clazz != null ; Class < ? > entityClass = clazz ; List < Field > list = new ArrayList < Field > ( ) ; while ( ! Object . class . equals ( entityClass ) && entityClass != null ) { list . addAll ( Arrays . asList ( entityClass . getDeclaredFields ( ) ) ) ; entityClass = entityClass . getSuperclass ( ) ; } return list ; }
lists all fields of a given class