class _Sets {

    public static <T> 
    Collector<T, ?, Set<T>> toUnmodifiable(Supplier<Set<T>> collectionFactory) {
        return Collectors.collectingAndThen(
                Collectors.toCollection(collectionFactory),
                Collections::unmodifiableSet);
    }

}