@SuppressWarnings("unchecked")
	// we checked the elements of the collection
	public static <T> Collection<T> asCollection(Collection<?> collection, Class<T> clazz) {
		for (Object object : collection) {
			if (!clazz.isAssignableFrom(object.getClass())) {
				throw new IllegalArgumentException("Given collection contains data that is not " +
					"the type: " + clazz + ".  Value: " + object.getClass());
			}
		}

		return (Collection<T>) collection;
	}
Checks that the elements in the given collection are of the type specified by
<code>clazz</code> and then casts the collection to be of the specified type.

@param collection  the source collection
@param clazz the class of T
@return a casted list of type T
@throws IllegalArgumentException if the given collection contains elements that are
        not of the type specified by <code>clazz</code>.
Ghidra/Framework/Generic/src/main/java/util/CollectionUtils.java