示例#1
0
  /**
   * Adds an <code>Application</code> or a <code>Library</code> to the <code>Project</code>.
   *
   * @param builder An instance of the <code>Application</code> or a <code>Library</code> class.
   */
  public void addBuilder(Builder builder) {
    String name = Integer.toString(builder.hashCode());
    dependencies.put(name, builder);

    if (!dependencies.containsVertex(name)) {
      dependencies.addVertex(new Vertex<String, Builder>(name));
    }
  }
示例#2
0
 /**
  * Instructs the <code>Project</code> that one <code>Builder</code> depends on the other. Both
  * <code>Builder</code> instances must first be added to this <code>Project</code>.
  *
  * <p><code>builder1</code> depends on <code>builder2</code>.
  *
  * @param builder1 A <code>Builder</code>. This <code>Builder</code> depends on the other.
  * @param builder2 A <code>Builder</code>.
  */
 public void dependsOn(Builder builder1, Builder builder2) {
   String head = Integer.toString(builder1.hashCode()),
       tail = Integer.toString(builder2.hashCode());
   if (!head.equals(tail)
       && dependencies.containsKey(head)
       && dependencies.containsKey(tail)
       && !dependencies.dependencyExists(head, tail)) {
     dependencies.addDependency(head, tail);
   }
 }
示例#3
0
  /**
   * Gets the build order for the <code>Project</code>. The build order is determined by the
   * dependencies among <code>Builder</code> instances.
   *
   * @return <code>Iterator</code> build order; the elements are either instance of the <code>
   *     Application</code> class or the <code>Library</code> class.
   */
  public Iterator<Builder> getBuildOrder() {
    final List<Builder> buildOrder = new ArrayList<Builder>(dependencies.size());

    Algorithms.topologicalSort(
        dependencies,
        new Visitor<Vertex<String, Builder>>() {
          public void visit(Vertex<String, Builder> v) {
            String name = v.getWeight();
            buildOrder.add(dependencies.get(name));
          }
        });

    return buildOrder.iterator();
  }
示例#4
0
 /**
  * Removes an <code>Application</code> or a <code>Library</code> from the <code>Project</code>.
  *
  * @param builder An instance of the <code>Application</code> or a <code>Library</code> class.
  */
 public void removeBuilder(Builder builder) {
   String name = Integer.toString(builder.hashCode());
   dependencies.remove(name);
   dependencies.removeVertex(name);
 }