public static List < String > getTypeParameters ( final String type ) { if ( type . charAt ( 0 ) != ' ' ) return emptyList ( ) ; int lastStart = type . indexOf ( ' ' ) + 1 ; final List < String > parameters = new ArrayList <> ( ) ; if ( lastStart > 0 ) { int depth = 0 ; for ( int i = lastStart ; i < type . length ( ) - 2 ; i ++ ) { final char c = type . charAt ( i ) ; if ( c == ' ' ) depth ++ ; else if ( c == ' ' ) depth -- ; else if ( c == ' ' && depth == 0 ) { parameters . add ( type . substring ( lastStart , i + 1 ) ) ; lastStart = i + 1 ; } } } return parameters ; }
Returns the type parameters of the given type . Will be an empty list if the type is not parametrized .