public static String getGenericString ( Field field ) { String fieldDescription = field . toGenericString ( ) ; List < String > splitResult = new ArrayList < String > ( ) ; char [ ] charResult = fieldDescription . toCharArray ( ) ; boolean isFinished = false ; int separatorIndex = fieldDescription . indexOf ( " " ) ; int previousIndex = 0 ; while ( ! isFinished ) { // if previous character is "," don't cut the string int position = separatorIndex - 1 ; char specialChar = charResult [ position ] ; boolean isSpecialChar = true ; if ( specialChar != ' ' && specialChar != ' ' ) { if ( specialChar == ' ' ) { String specialString = null ; try { specialString = fieldDescription . substring ( position - "extends" . length ( ) , position + 1 ) ; if ( isNull ( specialString ) || ! " extends" . equals ( specialString ) ) isSpecialChar = false ; } catch ( IndexOutOfBoundsException e ) { isSpecialChar = false ; } } else isSpecialChar = false ; } if ( ! isSpecialChar ) { splitResult . add ( fieldDescription . substring ( previousIndex , separatorIndex ) ) ; previousIndex = separatorIndex + 1 ; } separatorIndex = fieldDescription . indexOf ( " " , separatorIndex + 1 ) ; if ( separatorIndex == - 1 ) isFinished = true ; } for ( String description : splitResult ) if ( ! isAccessModifier ( description ) ) return description ; return null ; }
Splits the fieldDescription to obtain his class type generics inclusive .