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;
    }
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;
    }
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.

@param expectedSuperClass
The generic super class.
@param genericTypeParameterIndex
The index, e.g. 0 for the first.
@return The type parameter.
Determines the type parameter for a generic super class .