public static <T> Set<T> union(Collection<Set<T>> collections) {
        int count = 0;
        for (Collection<? extends T> collection : collections) {
            count += collection.size();
        }
        if (count == 0) {
            return Collections.emptySet();
        }
        Set<T> set = newSetWithExpectedSize(count);
        for (Collection<? extends T> collection : collections) {
            set.addAll(collection);
        }
        return set;
    }
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