private static Optional<Set<String>> intersectIfChanged(
            Collection<String> subject,
            Collection<String> other,
            boolean exclude
    ) {
        Set<String> temp = new HashSet<>(subject);
        if (exclude) {
            temp.removeAll(other);
        } else {
            temp.retainAll(other);
        }
        return temp.size() == subject.size() ? Optional.empty() : Optional.of(temp);
    }
Utilities for {@link ExcludeTags} and {@link IncludeTags}.
smithy-build/src/main/java/software/amazon/smithy/build/transforms/TagUtils.java