コード例 #1
0
  public List sort() {
    sortNodes();

    List result = new ArrayList();
    for (Node node : nodes) {
      result.add(node.getObject());
    }
    return result;
  }
コード例 #2
0
  public Node add(final Object object, final Object... dependencies) {
    Node node = registeredObjects.get(object);
    if (node == null) {
      node = new Node(object);
      nodes.add(node);
      registeredObjects.put(object, node);
    }

    if (dependencies != null) {
      for (Object dependency : dependencies) {
        Node depNode = add(dependency);
        node.addDependency(depNode);
      }
    }
    return node;
  }
コード例 #3
0
ファイル: Node.java プロジェクト: Zidanela/sonar-git
  private int resolveOrder(String path) throws CyclicDependenciesException {
    seen = true;
    try {
      int highOrder = -1;
      for (Node dep : dependencies) {
        if (dep.seen) {
          throw new CyclicDependenciesException(path + " -> " + dep.toString());
        }
        highOrder = Math.max(highOrder, dep.resolveOrder(path + " -> " + dep.toString()));
      }

      order = highOrder + 1;
      return order;

    } finally {
      seen = false;
    }
  }
コード例 #4
0
  private void verify() {
    for (Node node : nodes) {
      node.reset();
    }

    for (Node node : nodes) {
      for (Node dep : node.getDependencies()) {
        if (!nodes.contains(dep)) {
          throw new SonarException(
              "A dependent node ("
                  + dep
                  + ") of "
                  + " ("
                  + node
                  + ") was not included in the nodes list.");
        }
      }

      node.resolveOrder();
    }
  }