public static <T> Set<T> toSet(Collection<T> values) {
        if (values instanceof Set<T> set) {
            return set;
        }
        if (values.isEmpty()) {
            return Collections.emptySet();
        }
        return new UnifiedSet<>(values);
    }
Note that the method only checks the immutable classes used by Turms.
turms-server-common/src/main/java/im/turms/server/common/infra/collection/CollectionUtil.java