@SuppressWarnings("unchecked")
	// we checked the elements of the list
	public static <T> List<T> asList(List<?> list, Class<T> clazz) {

		if (list == null) {
			return new ArrayList<>();
		}

		for (Object object : list) {
			if (!clazz.isAssignableFrom(object.getClass())) {
				throw new IllegalArgumentException("Given list contains data that is not " +
					"the type: " + clazz + ".  Value: " + object.getClass());
			}
		}

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

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