public static Optional < Field > getField ( Class < ? > type , final String fieldName ) { Optional < Field > field = Iterables . tryFind ( newArrayList ( type . getDeclaredFields ( ) ) , havingFieldName ( fieldName ) ) ; if ( ! field . isPresent ( ) && type . getSuperclass ( ) != null ) { field = getField ( type . getSuperclass ( ) , fieldName ) ; } return field ; }
Finds the first Field with given field name in the Class and in its super classes .