package org.jerkar.api.depmanagement;

import java.util.Collections;
import java.util.List;

public class JkDependencyNode {

    private final JkVersionedModule module;

    private final List<JkDependencyNode> children;

    public JkDependencyNode(JkVersionedModule module, List<JkDependencyNode> children) {
        super();
        this.module = module;
        this.children = Collections.unmodifiableList(children);
    }







}

@@ -88,13 +88,200 @@
 l.Li
-st;%0D%0A
+nkedList;%0D%0Aimport java.util.List;%0D%0A%0D%0A/**%0D%0A * A representation of a node in a dependency tree. A dependency tree may be represented simply by its root node.%0D%0A *%0D%0A * @author Jerome Angibaud%0D%0A */
 %0D%0Apu
@@ -410,24 +410,144 @@
 hildren;%0D%0A%0D%0A
+    /**%0D%0A     * Constructs a node for the specified versioned module having the specified direct descendants.%0D%0A     */%0D%0A
     public J
@@ -743,27 +743,1239 @@
 ;%0D%0A    %7D%0D%0A%0D%0A
-%0D%0A%0D%0A%0D%0A
+    /**%0D%0A     * Returns a merge of this dependency node with the specified one. The root versioned module id of the two node must be equals.%0D%0A     * The children of the merged node is a union of the two node children.%0D%0A     */%0D%0A    public JkDependencyNode merge(JkDependencyNode other) %7B%0D%0A        if (!this.module.equals(other.module)) %7B%0D%0A            throw new IllegalArgumentException(%22Try to merge dependency tree of %22 + this.module + %22 with dependency tree of %22 + other.module + %22. Should be the same.%22);%0D%0A        %7D%0D%0A        final List%3CJkDependencyNode%3E list = new LinkedList%3CJkDependencyNode%3E(this.children);%0D%0A        for (final JkDependencyNode otherNode : other.children) %7B%0D%0A            final JkVersionedModule otherChild = other.module;%0D%0A            if (! childrenContains(otherChild.moduleId())) %7B%0D%0A                list.add(otherNode);%0D%0A            %7D%0D%0A        %7D%0D%0A        return new JkDependencyNode(module, list);%0D%0A    %7D%0D%0A%0D%0A    private boolean childrenContains(JkModuleId moduleId) %7B%0D%0A        for (final JkDependencyNode dependencyNode : this.children) %7B%0D%0A            if (dependencyNode.module.moduleId().equals(moduleId)) %7B%0D%0A                return true;%0D%0A            %7D%0D%0A        %7D%0D%0A        return false;%0D%0A    %7D
 %0D%0A%0D%0A%0D%0A%7D%0D%0A

add merge method for dependency node