public static Class < ? > getTypeParameter ( Class < ? > genericType , Class < ? > type ) { Type [ ] genericInterfaces = type . getGenericInterfaces ( ) ; for ( Type genericInterface : genericInterfaces ) { if ( genericInterface instanceof ParameterizedType ) { ParameterizedType parameterizedType = ( ParameterizedType ) genericInterface ; if ( genericType . equals ( parameterizedType . getRawType ( ) ) ) { Type typeParameter = ( ( ParameterizedType ) genericInterface ) . getActualTypeArguments ( ) [ 0 ] ; if ( typeParameter instanceof Class < ? > ) { return ( Class < ? > ) typeParameter ; } } } } return null ; }
Determines the type of a class implementing a generic interface with one type parameter .