public static Set<String> cleanItems(final Set<String> items,
                                         final Function<String, String> formatter) {
        if (NullSafe.isEmptyCollection(items)) {
            return Collections.emptySet();
        } else {
            Stream<String> stringStream = NullSafe.stream(items)
                    .filter(Objects::nonNull);
            if (formatter != null) {
                stringStream = stringStream.map(formatter);
            }
            return stringStream
                    .filter(NullSafe::isNonEmptyString)
                    .collect(Collectors.toUnmodifiableSet());
        }
    }
Removes null items, applies formatter on each item, then removes any empty items.
stroom-util/src/main/java/stroom/util/collections/CollectionUtil.java