public ModuleVersionResolveState clearSelection() {
   ModuleVersionResolveState previousSelection = selected;
   selected = null;
   for (ModuleVersionResolveState version : versions.values()) {
     version.state = ModuleState.Conflict;
   }
   return previousSelection;
 }
 public void select(ModuleVersionResolveState selected) {
   assert this.selected == null;
   this.selected = selected;
   for (ModuleVersionResolveState version : versions.values()) {
     version.state = ModuleState.Evicted;
   }
   selected.state = ModuleState.Selected;
 }
 public void restart(ModuleVersionResolveState selected) {
   select(selected);
   for (ModuleVersionResolveState version : versions.values()) {
     version.restart(selected);
   }
   for (ModuleVersionSelectorResolveState selector : selectors) {
     selector.restart(selected);
   }
   for (DependencyEdge dependency : new ArrayList<DependencyEdge>(unattachedDependencies)) {
     dependency.restart(selected);
   }
   unattachedDependencies.clear();
 }
 private ConfigurationNode(
     ResolvedConfigurationIdentifier id,
     ModuleVersionResolveState moduleRevision,
     ResolveState resolveState) {
   this.id = id;
   this.moduleRevision = moduleRevision;
   this.resolveState = resolveState;
   this.metaData = moduleRevision.metaData.getConfiguration(id.getConfiguration());
   moduleRevision.addConfiguration(this);
 }
 public ResolveState(
     ComponentResolveResult rootResult,
     String rootConfigurationName,
     DependencyToComponentIdResolver idResolver,
     ComponentMetaDataResolver metaDataResolver,
     DependencyToConfigurationResolver dependencyToConfigurationResolver) {
   this.idResolver = idResolver;
   this.metaDataResolver = metaDataResolver;
   this.dependencyToConfigurationResolver = dependencyToConfigurationResolver;
   ModuleVersionResolveState rootVersion = getRevision(rootResult.getId());
   rootVersion.setMetaData(rootResult.getMetaData());
   root =
       new RootConfigurationNode(
           rootVersion,
           new ResolvedConfigurationIdentifier(rootVersion.id, rootConfigurationName),
           this);
   nodes.put(root.id, root);
   root.moduleRevision.module.select(root.moduleRevision);
 }
    /** @return The module version, or null if there is a failure to resolve this selector. */
    public ModuleVersionResolveState resolveModuleRevisionId() {
      if (targetModuleRevision != null) {
        return targetModuleRevision;
      }
      if (failure != null) {
        return null;
      }

      idResolveResult = new DefaultBuildableComponentIdResolveResult();
      resolver.resolve(dependencyMetaData, idResolveResult);
      if (idResolveResult.getFailure() != null) {
        failure = idResolveResult.getFailure();
        return null;
      }

      targetModuleRevision = resolveState.getRevision(idResolveResult.getModuleVersionId());
      targetModuleRevision.addResolver(this);
      targetModuleRevision.selectionReason = idResolveResult.getSelectionReason();
      targetModule = targetModuleRevision.module;
      targetModule.addSelector(this);

      return targetModuleRevision;
    }
    private void calculateTargetConfigurations() {
      targetConfigurations.clear();
      ComponentResolveMetaData targetModuleVersion = targetModuleRevision.getMetaData();
      if (targetModuleVersion == null) {
        // Broken version
        return;
      }

      Set<ConfigurationMetaData> targetConfigurations =
          resolveState.dependencyToConfigurationResolver.resolveTargetConfigurations(
              dependencyMetaData, from.metaData, targetModuleVersion);
      for (ConfigurationMetaData targetConfiguration : targetConfigurations) {
        ConfigurationNode targetConfigurationNode =
            resolveState.getConfigurationNode(targetModuleRevision, targetConfiguration.getName());
        this.targetConfigurations.add(targetConfigurationNode);
      }
    }
 public ComponentSelectionReason getSelectionReason() {
   return targetModuleRevision == null
       ? idResolveResult.getSelectionReason()
       : targetModuleRevision.getSelectionReason();
 }
 private ModuleVersionResolveException getFailure() {
   return failure != null ? failure : targetModuleRevision.getFailure();
 }
 public ComponentIdentifier getComponentId() {
   return moduleRevision.getComponentId();
 }