public static List < Field > getAllFields ( List < Field > fields , Class < ? > clazz ) { for ( Field field : clazz . getDeclaredFields ( ) ) { fields . add ( field ) ; } if ( clazz . getSuperclass ( ) != null ) { fields = getAllFields ( fields , clazz . getSuperclass ( ) ) ; } return fields ; }
This static method will get ALL fields for this class including any inherited ones .