Set<PatternDescription> (@NotNull Set<? extends PatternDescription> patterns, Set<? extends PatternDescription> toRemove, Set<? extends PatternDescription> toAdd) { Set<PatternDescription> result = new HashSet<>(); for (PatternDescription pattern : patterns) { if (!toRemove.contains(pattern)) { result.add(pattern); } } result.addAll(toAdd); return result; }