public static Type getTypeArgument(Type type) {
        if (!(type instanceof ParameterizedType)) {
            return null;
        }
        return ((ParameterizedType) type).getActualTypeArguments()[0];
    }
public static Type getTypeArgument ( Type type ) { if ( ! ( type instanceof ParameterizedType ) ) { return null ; } return ( ( ParameterizedType ) type ) . getActualTypeArguments ( ) [ 0 ] ; }
Get the generic argument, or the first if the type has more than one.

@param type the type to get arguments
@return the generic argument, null if type is not parameterized