public void commit() {
    Set<String> existingModules = new HashSet<>();
    myModulesSupplier.get().stream().map(Module::getName).forEach(existingModules::add);

    myState.names = new HashMap<>();
    myNamesMap.forEach((module, lib) -> {
      if (existingModules.contains(module)) {
        myState.names.put(module, lib);
      }
    });

    myState.substitutions = new HashMap<>();
    for (Map.Entry<String, Collection<String>> entry : mySubstitutions.entrySet()) {
      if (!existingModules.contains(entry.getKey())) continue;
      Collection<String> value = entry.getValue();
      if (value != null && !value.isEmpty()) {
        myState.substitutions.put(entry.getKey(), new TreeSet<>(value));
      }
    }
  }
public void commit()