public static <T extends Collection> T toCollection(final Object obj, final Class<T> clazz) {
        return FunctionUtils.doUnchecked(() -> {
            val results = toCollection(obj);
            if (clazz.isInterface()) {
                throw new IllegalArgumentException("Cannot accept an interface " + clazz.getSimpleName() + " to create a new object instance");
            }
            val col = clazz.getDeclaredConstructor().newInstance();
            col.addAll(results);
            return col;
        });
    }
To collection t.

@param <T>   the type parameter
@param obj   the obj
@param clazz the clazz
@return the t
core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/CollectionUtils.java