public static List < Field > getAllDeclaredFields ( Class < ? extends ParaObject > clazz ) { LinkedList < Field > fields = new LinkedList <> ( ) ; if ( clazz == null ) { return fields ; } Class < ? > parent = clazz ; do { for ( Field field : parent . getDeclaredFields ( ) ) { if ( ! Modifier . isTransient ( field . getModifiers ( ) ) && ! field . getName ( ) . equals ( "serialVersionUID" ) ) { fields . add ( field ) ; } } parent = parent . getSuperclass ( ) ; } while ( ! parent . equals ( Object . class ) ) ; return fields ; }
Returns a list of all declared fields in a class . Transient and serialVersionUID fields are skipped . This method scans parent classes as well .