/** * Generates a unique signature for a {@link Type}. */ private static String createTypeId(Type type) { if (type instanceof Class<?>) { return Class.class.cast(type).getName(); } if (type instanceof ParameterizedType) { return createTypeId(((ParameterizedType) type).getRawType()) + Stream.of(((ParameterizedType) type).getActualTypeArguments()) .map(CdiSpiHelper::createTypeId) .collect(joining(",", "<", ">")); } if (type instanceof TypeVariable<?>) { return TypeVariable.class.cast(type).getName(); } if (type instanceof GenericArrayType) { return createTypeId(GenericArrayType.class.cast(type).getGenericComponentType()); } throw new UnsupportedOperationException("Unable to create type id for type [" + type + "]"); }