Set<WatchRequest> (@NotNull Collection<WatchRequest> watchRequests, @Nullable Collection<String> recursiveRoots, @Nullable Collection<String> flatRoots) { assertNullOrEmpty(flatRoots); if (myDisposed) { assertNullOrEmpty(recursiveRoots); return Collections.emptySet(); } else { Set<String> oldPaths = ContainerUtil.map2Set(watchRequests, it -> it.getRootPath()); Set<String> newPaths = new HashSet<>(recursiveRoots); Set<String> toRemove = new HashSet<>(oldPaths); toRemove.removeAll(newPaths); for (String rootPath : toRemove) { assertTrue(myRemove.remove(rootPath)); } Set<String> toAdd = new HashSet<>(newPaths); toAdd.removeAll(oldPaths); for (String rootPath : toAdd) { assertTrue(myAdd.remove(rootPath)); } return ContainerUtil.map2Set(newPaths, rootPath -> new MockKey(rootPath, true)); } }