public static Class < ? > forType ( Type type ) { if ( type instanceof Class ) { return ( Class < ? > ) type ; } if ( type instanceof ParameterizedType ) { return forType ( ( ( ParameterizedType ) type ) . getRawType ( ) ) ; } if ( ! ( type instanceof GenericArrayType ) ) { return null ; } Type componentType = ( ( GenericArrayType ) type ) . getGenericComponentType ( ) ; Class < ? > componentClass = forType ( componentType ) ; return componentClass != null ? Array . newInstance ( componentClass , 0 ) . getClass ( ) : null ; }
Get the underlying class for a type or null if the type is a variable type .