public static List < Field > findAllFields ( Class < ? > type ) { List < Field > fields = new LinkedList <> ( ) ; if ( type != null ) { addAll ( fields , type . getDeclaredFields ( ) ) ; if ( type . getSuperclass ( ) != null ) { fields . addAll ( findAllFields ( type . getSuperclass ( ) ) ) ; } } return fields ; }
Get all fields on given object and look for fields of super classes .