protected < T > Class < T > getTypeParameter ( Class < ? > expectedSuperClass , int genericTypeParameterIndex ) { Class < ? extends AbstractScannerPlugin > thisClass = this . getClass ( ) ; if ( ! thisClass . getSuperclass ( ) . equals ( expectedSuperClass ) ) { throw new IllegalStateException ( "Cannot determine type argument of " + thisClass . getName ( ) ) ; } Type genericSuperclass = thisClass . getGenericSuperclass ( ) ; Type typeParameter = ( ( ParameterizedType ) genericSuperclass ) . getActualTypeArguments ( ) [ genericTypeParameterIndex ] ; if ( typeParameter instanceof ParameterizedType ) { return ( Class < T > ) ( ( ParameterizedType ) typeParameter ) . getRawType ( ) ; } return ( Class < T > ) typeParameter ; }
Determines the type parameter for a generic super class .