void (String qualifiedName) { final Set<String> replaced = new LinkedHashSet<>(); for (String currentPattern : patterns) { if (myOldName.equals(currentPattern)) { replaced.add(qualifiedName); myOldName = qualifiedName; } else { replaced.add(currentPattern); } } patterns.clear(); patterns.addAll(replaced); }