private void exportRoots(
    final Function<? super OrderRootType, String[]> getUrls,
    final BiPredicate<? super String, ? super OrderRootType> isValid,
    final BiConsumer<? super String, ? super OrderRootType> removeRoot,
    final BiConsumer<? super String, ? super OrderRootType> addRoot,
    final TriConsumer<? super String, ? super Boolean, ? super OrderRootType> addJarDir,
    final Consumer<? super String> addExcludedRoot) {

    // first, clean the target container optionally preserving invalid paths
    for (OrderRootType type : OrderRootType.getAllTypes()) {
      for (String url : getUrls.apply(type)) {
        if (!myKeepInvalidUrls || isValid.test(url, type)) {
          removeRoot.accept(url, type);
        }
      }
    }

    // apply editor's state to the target container
    for (OrderRootType type : myRoots.keySet()) {
      for (LightFilePointer pointer : myRoots.get(type)) {
        if (!isJarDirectory(pointer.getUrl(), type)) {
          addRoot.accept(pointer.getUrl(), type);
        }
      }
    }
    for (Map.Entry<OrderRootType, Collection<String>> entry : myJarDirectoryUrls.entrySet()) {
      OrderRootType type = entry.getKey();
      for (String url : entry.getValue()) {
        addJarDir.accept(url, false, type);
      }
    }
    for (Map.Entry<OrderRootType, Collection<String>> entry : myJarDirectoryRecursiveUrls.entrySet()) {
      OrderRootType type = entry.getKey();
      for (String url : entry.getValue()) {
        addJarDir.accept(url, true, type);
      }
    }
    for (LightFilePointer root: myExcludedRoots) {
      addExcludedRoot.accept(root.getUrl());
    }
  }
private void exportRoots(
    final Function<? super OrderRootType, String[]> getUrls,
    final BiPredicate<? super String, ? super OrderRootType> isValid,
    final BiConsumer<? super String, ? super OrderRootType> removeRoot,
    final BiConsumer<? super String, ? super OrderRootType> addRoot,
    final TriConsumer<? super String, ? super Boolean, ? super OrderRootType> addJarDir,
    final Consumer<? super String> addExcludedRoot)