public static int getTypeVariablePosition ( GenericDeclaration genericDeclartion , TypeVariable < ? > typeVariable ) { int position = - 1 ; TypeVariable < ? > [ ] typeVariableDeclarationParameters = genericDeclartion . getTypeParameters ( ) ; // Try to find the position of the type variable in the class for ( int i = 0 ; i < typeVariableDeclarationParameters . length ; i ++ ) { if ( typeVariableDeclarationParameters [ i ] . equals ( typeVariable ) ) { position = i ; break ; } } return position ; }
Tries to find the position of the given type variable in the type parameters of the given class . This method iterates through the type parameters of the given class and tries to find the given type variable within the type parameters . When the type variable is found the position is returned otherwise - 1 .