How to create Java Tree Structured object - java

I am working on a eclipse rcp project where I need to create a treeviewer out of TreeStructured Java object. Currently I have hardcorded the Java objects to create the structure and that is working fine. I need to create a method which calculates all the Parents and children object and form the tree structure. It should be a recursive method. I wrote a recursive method to generate a
tree structured java object. But it does not work properly.
I dont know where exactly the problem. request you to help on this. Please find the code below.
private FileParent getInput() {
FileParent root = new FileParent("Root");
FileParent A = new FileParent("A");
FileParent a1 = new FileParent("A1");
FileObject a11 = new FileObject("A11");
a1.addChild(a11);
FileObject a2 = new FileObject("A2");
A.addChild(a1);
A.addChild(a2);
FileParent b = new FileParent("B"); FileObject b1 = new
FileObject("B1"); FileObject b2 = new FileObject("B2");
b.addChild(b1); b.addChild(b2);
root.addChild(A);
// root.addChild(b);
return root;
}
My recursive method which is to traverse through all the Parents and children objects
and creates the tree structured object.
FileParent root1 = new FileParent("Root");
public FileParent getChildren(FileParent root) {
if (!root.hasChildren()) {
return root;
}
if (root != null && root.hasChildren()) {
FileObject[] children = root.getChildren();// size two
for (FileObject fileObject : children) { // 2 times
// here children will be the folders
if (fileObject instanceof FileParent) {
FileParent folder = (FileParent) fileObject;
// root1.setParent(folder.getParent());
// if (root1.getParent() != null) {
root1.addChild(folder);
// }
getChildren((FileParent) folder);
} else {
System.out.println("FileName: " + fileObject.getName());
// root1.setParent(fileObject.getParent());
// if (root1.getParent() != null) {
root1.addChild(fileObject);
// }
}
}
}
return root1;
}
public class FileObject {
private String name;
private FileParent parent;
public FileObject(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setParent(FileParent parent) {
this.parent = parent;
}
public FileParent getParent() {
return parent;
}
public String toString() {
return getName();
}
}
public class FileParent extends FileObject {
/**
*
*/
private List<FileObject> children;
public FileParent(String name) {
super(name);
children = new ArrayList<FileObject>();
}
public void addChild(FileObject child) {
// if (children.contains(child)) {
children.add(child);
child.setParent(this);
// }
}
public void removeChild(FileObject child) {
children.remove(child);
child.setParent(null);
}
public FileObject[] getChildren() {
return (FileObject[]) children.toArray(new FileObject[children.size()]);
}
public boolean hasChildren() {
return children.size() > 0;
}
}

In Swing there is interface TreeModel with default implementation Supposed to be used in JTree and generally not written the best way (like no generics), but can do the job.

There is one method in treeviewer.setInput(Object obj).If I pass getInput() as parameter It will work fine. But if I pass getChildren() which is my recursive method it does not work.
Do you mean you are calling treeviewer.setInput(foo.getChildren())? This is definitely wrong. Read this article: http://www.vogella.com/articles/EclipseJFaceTree/article.html.
Basically, you need to 1) implement ITreeContentProvider to provide the tree structure; 2) implement ILabelProvider to provide text and images; 3) call
treeViewer.setContentProvider(yourContentProvider);
treeViewer.setLabelProvider(yourLabelProvider);
treeviewer.setInput(new Object()); // or anything for which your content provider returns correct roots

Related

Calling an Instance method by the instance name as a String in java

In class Tree I got error message:
The method removeparent() is undefined for the type String.
I want to convert string "Grandchild3" to object which instance MyTreeNode class, then I can use removep("Grandchild3") call the method like this Grandchild3.removeparent().
How can I do this?
Here's class MyTreeNode:
public class MyTreeNode<T>{
private T data = null;
private List<MyTreeNode> children = new ArrayList<>();
private MyTreeNode parent = null;
public MyTreeNode(T data) {
this.data = data;
}
public void addChild(MyTreeNode child) {
child.setParent(this);
this.children.add(child);
}
public void addChild(T data) {
MyTreeNode<T> newChild = new MyTreeNode<>(data);
newChild.setParent(this);
children.add(newChild);
}
public void addChildren(List<MyTreeNode> children) {
for(MyTreeNode t : children) {
t.setParent(this);
}
this.children.addAll(children);
}
public List<MyTreeNode> getChildren() {
return children;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
private void setParent(MyTreeNode parent) {
this.parent = parent;
}
public MyTreeNode getParent() {
return parent;
}
public void removeparent() {
this.parent = null;
}
public void removeChild(MyTreeNode<T> child)
{
this.children.remove(child);
}
}
Here's class Tree:
public class Tree {
public static void main(String[] args) throws ClassNotFoundException {
// TODO Auto-generated method stub
MyTreeNode<String> root = new MyTreeNode<>("Root");
MyTreeNode<String> child1 = new MyTreeNode<>("Child1");
child1.addChild("Grandchild1");
child1.addChild("Grandchild2");
MyTreeNode<String> child2 = new MyTreeNode<>("Child2");
child2.addChild("Grandchild3");
root.addChild(child1);
root.addChild(child2);
root.addChild("Child3");
root.addChildren(Arrays.asList(
new MyTreeNode<>("Child4"),
new MyTreeNode<>("Child5"),
new MyTreeNode<>("Child6")
));
for(MyTreeNode<String> node : root.getChildren()) {
System.out.println(node.getData());
}
printTree(root, " ");
removep("Grandchild3"); //error message"The method removeparent() is undefined for the type String"
printTree(root, " ");
}
private static void printTree(MyTreeNode<String> node, String appender) {
System.out.println(appender+node.getData());
for (MyTreeNode each : node.getChildren()){
printTree(each, appender + appender);
}
}
public static void removep(MyTreeNode<String> node)
{
node.getParent().removeChild(node);
node.removeparent();
}
}
So basically what you want is to convert a string to a class object. Now there are probably several ways it could be done, but in the context used here it seems like you could simply pass the appropriate object instead of messing with strings.
So in your case, the most appropriate way to do so would be to create a method which receives a string name and the top node of your tree and iterates over the tree to find the node with the given name. When found the method returns the node.
Then you can use that method to get the node from the name and then call removep.

How to create a tree-type object in java? [duplicate]

This question already has answers here:
How to implement a tree data-structure in Java?
(27 answers)
Closed 7 years ago.
I've always wondered what is the best practice to create objects which have lists within lists within lists etc. Let's say I have this sort of object :
root = new CarrierTreeNode(null,
new CarrierTreeNode[] {
new CarrierTreeNode(new CarrierTreeItem("item1"), new CarrierTreeNode[] {
new CarrierTreeNode(new CarrierTreeItem("item1.1"))
}),
new CarrierTreeNode(new CarrierTreeItem("item2"), new CarrierTreeNode[] {
new CarrierTreeNode(new CarrierTreeItem("item2.1"))
})
});
and I want to generate this dynamically and also access and modify the lists/arrays within it dynamically. Is there a design pattern for this?
Thank you.
To make it more clear, the constructor used here is like this : node (item, node[])
You might want to have a look at the composite pattern.
In short, this is used when Object A holds a collection of Object A.
This pattern / data structure allows easy recursive behavior.
There are many sources, so if this doesn't suffice, simple go to google for more information, but here's a start:
https://en.wikipedia.org/wiki/Composite_pattern
As for the creation part, I'd typically use a factory or builder in that case, but the exact implementation vary. Say you had a 2d array if items, and you wanted to create these nodes according to this array.
public class NodeBuilder{
public CarrierTreeNode build(String[][] items){
CarrierTreeNode node = new CarrierTreeNode(null);
for(int i = 1; i < items.length; i++){
CarrierTreeNode nextNode = new CarrierTreeNode(new CarrierTreeItem(items[i][0]));
node.addNextNode(nextNode);
for(int j = 1; j < items[i].length; j++)
nextNode.addNextNode(new CarrierTreeItem(items[i][j]));
}
return node;
}
}
This would obviously only work for a structure of 3 layers. A recursive approach is preferable. You could create a system where build calls build n times, to create the depth you want. The problem is in acquiring the data, for that to work, the data must already be in the right structure, but just as strings.
If your strings are dynamically generated, so that the builder could figure out the data, it would be possible to make it work.
I propose this design hoping it will help you :
TreeElement iterface : the generic tree element type.
Item class that implements the TreeElement iterface :so it can be a
key for a tree node or a value of a tree node.
Node class that implements also the TreeElement interface so it can
be a base node or a value of a key.
This is the implementation :
interface TreeElement {
enum ElementType {
NODE, ITEM
};
public TreeElement getElement(Item item);
public Node addElement(Item item, TreeElement element);
public ElementType getType();
}
class Item implements TreeElement {
String name;
public Item(String name) {
super();
this.name = name;
}
#Override
public TreeElement getElement(Item item) {
return null;
}
#Override
public ElementType getType() {
return ElementType.ITEM;
}
#Override
public Node addElement(Item item, TreeElement element) {
return null;
}
#Override
public String toString() {
return "Item [" + name + "]";
}
#Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}
#Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Item other = (Item) obj;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
return true;
}
}
class Node implements TreeElement {
Map<Item, TreeElement> map;
{
map = new HashMap<>();
}
#Override
public TreeElement getElement(Item item) {
return map.get(item);
}
#Override
public ElementType getType() {
return ElementType.NODE;
}
public Node addElement(Item item, TreeElement element) {
this.map.put(item, element);
return this;
}
#Override
public String toString() {
return "Node " + map + " ";
}
}
Test the code :
Node node = new Node();
Item item = new Item("Item 1");
node.addElement(item, new Node().addElement(new Item("Level 1"), new Item("Item 1")));
System.out.println(node);
//Print : Node {Item [Item 1]=Node {Item [Level 1]=Item [Item 1]} }
TreeElement element = node.getElement(item);
if (element.getType().equals(ElementType.NODE)) {
element.addElement(new Item("Level 2"), new Node().addElement(new Item("Item 2.1"), new Item("Item 2.2")));
}
System.out.println(node);
//Print : Node {Item [Item 1]=Node {Item [Level 1]=Item [Item 1], Item [Level 2]=Node {Item [Item 2.1]=Item [Item 2.2]} } }
Important : equals() and hashcode() are critical for the behavior of the example especially equals(). They are used in the Map collections to determine if a collection contains a given element.
Most simple tree node implementation must contain one field for store data and list of own children.
public class Node<T> {
private T data;
private List<Node> list = new LinkedList<>();
public Node(){}
public Node(T data){
this.data = data;
}
public List<Node> getChildList() {
return list;
}
public void setData(T data) {
this.data = data;
}
public T getData() {
return data;
}
}
This class is ready to build simple tree structure:
Node<String> root = new Node<String>("Stark");
root.getChildList().add(new Node<String>("Benjen"));
Node<String> eddard = new Node<String>("Eddard");
root.getChildList().add(eddard);
eddard.getChildList().add(new Node<String>("Arya"));
This implementation is simplest but of cause not the best. Classically tree node provides information about parent and sibling nodes, methods for internal recursive search , control of cycle references and many other things (wiki describes it very detailed).

Object oriented design, designing a tree

I'm creating a (atypical)tree in Java that will be composed of three classes: node, branch and leaf
Each node stores the branches it is connected to in a HashSet. The branch is supposed to lead to a descendent node or a leaf, but I'm not sure how to code that. Would I just have two separate variables, one Node and one Leaf in the branch class, along with two sets of getters and setters, even though I will never use both? Is there a best practice in this regard?
I was thinking maybe make node and leaf subclasses of the same superclass, but they have absolutely nothing in common in terms of code(i.e. different variable types, functions, etc.).
EDIT:
Node references branches and
each Branch references a Node or a Leaf
I'd probably go with something like this:
interface BranchDestination {
boolean isLeaf();
}
class Node implements BranchDestination {
private Set branches;
public boolean isLeaf() {
return false;
}
...
}
class Leaf implements BranchDestination {
public boolean isLeaf() {
return true;
}
...
}
class Branch {
BranchDestination destination;
...
}
I do like the idea of defining an interface for the leaf / node classes, and implement that interface in each. I would define a simple function in that interface (syntax might be wrong below, but it's pseduo-ish code):
interface BranchItem {
public object[] GetVals();
}
public class Branch
{
public BranchItem item;
}
public class Leaf implements BranchItem
{
private object myVal = <your data here>;
public object[] GetVals() {
return new object[] { myVal };
}
}
public class Node implements BranchItem
{
private myBranches[] = <List of Branches>;
public object[] GetVals() {
object[] myArray = new object[];
foreach (BranchItem b in myBranches)
{
myArray.addTo(b.item.GetVals());
}
return myArray;
}
}
When traversing your node, simply iterate over the Branches and call GetVals().
The Leaf class will simply returns it's stored value.
The Node Class will recursively loop over it's branches, calling GetVals() on each and add it to it's own returned array.
This is but a simple implementation. If you want sort order, handle collisions or duplicate data, or anything of that nature it could get more complicated.
Make the Leaf class with the basic information.
Make the Branch class which holds references to Leafs.
Make the Node class which holds references to Brahces.
Then try look up Recursion and how to use it to make such constructs :)
Here is my go at it. Though not very elegant, it gets the job done.
Here is the Leaf class:
public class Leaf {
private String text;
public Leaf(String text) {
this.text = text;
}
public String getText() {
return text;
}
public void setString(String newString) {
text = newString;
}
#Override
public String toString() {
return text;
}
}
And here is the Branch class:
public class Branch<T> {
private String text;
private HashSet<T> list;
public Branch(String text) {
this.text = text;
list = new HashSet<>();
}
public String getText() {
return text;
}
public void setText(String newText) {
text = newText;
}
public HashSet<T> getHashSet() {
return list;
}
public void setHashSet(HashSet<T> newList) {
list = newList;
}
public String getAllLeaves() {
StringBuilder sb = new StringBuilder();
sb.append(text).append("\n");
for(T t : list) {
sb.append("\t\t");
sb.append(t.toString()).append("\n");
}
return sb.toString();
}
#Override
public String toString() {
return text;
}
}
Lastly the Node class:
public class Node<T> {
private String text;
private HashSet<T> list;
public Node(String text) {
this.text = text;
list = new HashSet<>();
}
public String getText() {
return text;
}
public void setText(String newText) {
text = newText;
}
public HashSet<T> getHashSet() {
return list;
}
public void setHashSet(HashSet<T> newList) {
list = newList;
}
}
Little test program to try it out:
public class TreeConstruct {
public static void main(String[] args) {
Leaf l1 = new Leaf("Leaf 1");
Leaf l2 = new Leaf("Leaf 2");
Leaf l3 = new Leaf("Leaf 3");
Leaf l4 = new Leaf("Leaf 4");
Branch<Leaf> b1 = new Branch("Branch 1");
Branch<Leaf> b2 = new Branch("Branch 2");
Node<Branch> n1 = new Node("Node 1");
b1.getHashSet().add(l1);
b1.getHashSet().add(l2);
b1.getHashSet().add(l3);
b2.getHashSet().add(l4);
n1.getHashSet().add(b1);
n1.getHashSet().add(b2);
System.out.println(printNodeTree(n1));
}
public static String printNodeTree(Node<Branch> n) {
StringBuilder sb = new StringBuilder();
sb.append(n.getText()).append("\n");
for(Branch b : n.getHashSet()) {
sb.append("\t");
sb.append(b.getAllLeaves());
}
return sb.toString();
}
}
The output will be:
Node 1
Branch 1
Leaf 1
Leaf 3
Leaf 2
Branch 2
Leaf 4
Hope this helps!

populating a tree with the file revisions

`The requirement is that a tree has to be populated with revisions of a file.
I have a command that fetches all the revisions of a particular file from MKS(Versioning system).
using the following command in java
Process p = Runtime.getRuntime().exec("cmd /C "+cmd);
i get all the versions of file.c. now i want to populate the data onto a Tree structure. how do i do that?
try {
List<String> lVersions = new ArrayList<String>();
Process p = Runtime.getRuntime().exec("cmd /C "+cmd);
BufferedReader in = new BufferedReader( new InputStreamReader(p.getInputStream()));
String line = null;
while ((line = in.readLine()) != null)
{
lVersions .add(line);
}
}catch (IOException e)
{ e.printStackTrace();
}
lVersions contain the following output. It shows the all the revisions of a particular file. I need to populate this information on to a Tree structure.
1.1
1.1.1.1
1.1.1.2
1.1.1.3
1.1.1.4
1.2
1.3
I have created a Tree Class
public class Tree {
private List<Tree> children = new ArrayList<Tree>();
private String label;
private Tree parent;
private String root;
public Tree() {
super();
children = new ArrayList<Tree>();
}
public Tree(String label) {
this();
setData(label);
}
public void setRoot(String root){
this.root= root;
}
public String getRoot(){
return root;
}
public void addChild(Tree child) {
child.setParent(this);
children.add(child);
}
public void removeChild(Tree node) {
children.remove(node);
node.setParent(null);
}
public void setParent(Tree parent) {
this.parent = parent;
}
public Object[] getChildren() {
return children.toArray();
}
public Object getParent() {
return parent;
}
public String getLabel() {
return this.label;
}
public void setData(String label) {
this.label = label;
}
}
I have to generate the following tree structure and also remember the parent of each node. I am not asking for the code but some pointers as to how to start and to proceed would be very helpful !!!!
1.1
1.2 1.1.1.1
1.3 1.1.1.2
1.4 1.1.1.3
1.1.1.4
You will need to read the output of the command. See the API of ProcessBuilder for getting the output of the process as InputStream (output of process == your input, right?)
Parse the output into tree nodes. Each node has a parent reference and a list children with child nodes.

Construct a tree structure from list of string paths

I have a collection of string paths like ["x1/x2/x3","x1/x2/x4","x1/x5"] in a list.
I need to construct a tree-like structure from this list which can be iterated to get a pretty printed tree.
like this
x1
/ \
x5 x2
/ \
x3 x4
Any ideas/suggestions?
I believe that the problem can be attacked first by processing the list of strings EDIT: The correct answer chosen was an elegant implementation, other suggestions were good too.
Follow an implementation of naive implementation of a visitable tree:
class Tree<T> implements Visitable<T> {
// NB: LinkedHashSet preserves insertion order
private final Set<Tree> children = new LinkedHashSet<Tree>();
private final T data;
Tree(T data) {
this.data = data;
}
void accept(Visitor<T> visitor) {
visitor.visitData(this, data);
for (Tree child : children) {
Visitor<T> childVisitor = visitor.visitTree(child);
child.accept(childVisitor);
}
}
Tree child(T data) {
for (Tree child: children ) {
if (child.data.equals(data)) {
return child;
}
}
return child(new Tree(data));
}
Tree child(Tree<T> child) {
children.add(child);
return child;
}
}
interfaces for Visitor Pattern:
interface Visitor<T> {
Visitor<T> visitTree(Tree<T> tree);
void visitData(Tree<T> parent, T data);
}
interface Visitable<T> {
void accept(Visitor<T> visitor);
}
sample implementation for Visitor Pattern:
class PrintIndentedVisitor implements Visitor<String> {
private final int indent;
PrintIndentedVisitor(int indent) {
this.indent = indent;
}
Visitor<String> visitTree(Tree<String> tree) {
return new IndentVisitor(indent + 2);
}
void visitData(Tree<String> parent, String data) {
for (int i = 0; i < indent; i++) { // TODO: naive implementation
System.out.print(" ");
}
System.out.println(data);
}
}
and finally (!!!) a simple test case:
Tree<String> forest = new Tree<String>("forest");
Tree<String> current = forest;
for (String tree : Arrays.asList("x1/x2/x3", "x1/x2/x4", "x1/x5")) {
Tree<String> root = current;
for (String data : tree.split("/")) {
current = current.child(data);
}
current = root;
}
forest.accept(new PrintIndentedVisitor(0));
output:
forest
x1
x2
x3
x4
x5
Just split each path by its delimiter and then add them to a tree structure one by one.
i.e. if 'x1' does not exist create this node, if it does exist go to it and check if there is a child 'x2' and so on...
I'd make the tree one string at a time.
Make an empty tree (which has a root node - I assume there could be a path like "x7/x8/x9").
Take the first string, add x1 to the root node, then x2 to x1, then x3 to x2.
Take the second string, see that x1 and x2 are already there, add x4 to x2.
Do this for every path you have.
Create an Object Node which contains a parent (Node) and a List of children (Node).
First split the string using ",". For every splitted string you split the string using "/".
Search for the first node identifier (e.g x1) in the root list.
If you can find it, use the node to find the next node identifier (e.g. x2).
If you can not find a node, add the node to the last node you was able to find in the existing lists.
After you have created the list structure, you can print the list to the screen. I would make it recursive.
NOT TESTED, just an animation
public void print(List nodes, int deep) {
if (nodes == null || nodes.isEmpty()) {
return;
}
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < deep; i++) {
buffer.append("---");
}
for (Iterator iterator = nodes.iterator(); iterator.hasNext();) {
Node node = (Node)iterator.next();
System.out.println(buffer.toString() + " " + node.getIdentifier());
print(node.getChildren(), deep + 1);
}
}
public class Menu {
private String path;
private List<Menu> children;
public Menu(String path) {
this.path = path;
children = new ArrayList<>();
}
public void addChild(Menu child) {
children.add(child);
}
public List<Menu> getChildren() {
return children;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public Menu getChild(String data) {
for (Menu n : children)
if (n.path.equals(data)) {return n;}
return null;
}
}
Tree builder class:
public class MenuTree {
private Menu root;
public MenuTree() {
root = new Menu("");
}
public void add(String str) {
Menu current = root;
StringTokenizer s = new StringTokenizer(str, "/");
while (s.hasMoreElements()) {
str = (String) s.nextElement();
Menu child = current.getChild(str);
if (child == null) {
current.addChild(new Menu(str));
child = current.getChild(str);
}
current = child;
}
}
public JSONObject toJSON() {
try {
return new JSONObject(new ObjectMapper().writeValueAsString(this.root));
} catch (JsonProcessingException e) {
return null;
}
}
}
Usage:
String slist[] = new String[]{
"mnt/sdcard/folder1/a/b/file1.file",
"mnt/sdcard/folder1/a/b/file2.file",
"D/a/b/c.file",
};
MenuTree t = new MenuTree();
for (String s : slist) {
t.add(s);
}
System.out.println(t.toJSON().toString());
JSONObject result:
{"path":"","children":[{"path":"mnt","children":[{"path":"sdcard","children":[{"path":"folder1","children":[{"path":"a","children":[{"path":"b","children":[{"path":"file1.file","children":[]},{"path":"file2.file","children":[]}]}]}]}]}]},{"path":"D","children":[{"path":"a","children":[{"path":"b","children":[{"path":"c.file","children":[]}]}]}]}]}
Make your tree for every string in array.
Just split path for '/' , check whether the node exists in your tree or not, if it exists then move on... otherwise create a new node and add this node in childrens of parent node.
Iterate using recursion.
Following is model for tree's node.
Class Node{
string name;
List<Node> childrens;
Node(string name){
this.name = name;
this.childrens = new List<Node>();
}
}
This is way how I am doing tree from path (folders) structure. Maybe should help someone with basic logic.
Node:
public class Node {
private String path;
private List<Node> children;
public Node(String path) {
this.path = path;
children = new ArrayList<>();
}
public String getName() {
return getName(path);
}
private String getName(String path) {
String[] split = path.split("\\\\");
return split[split.length - 1];
}
public void addChild(Node child) {
children.add(child);
}
public List<Node> getChildren() {
return children;
}
public String getPath() {
return path;
}
}
FilesTree:
public class FilesTree {
private static final Logger log = Logger.getLogger(FilesTree.class.getName());
private FilesTree() {}
private static void createTree(Node root, List<String> paths) {
for (String path : paths) {
addNode(root, Arrays.asList(path.split("\\\\")), "");
}
}
private static void addNode(Node node, List<String> path, String nodePath) {
if (!path.isEmpty()) {
nodePath = nodePath.equals("") ? path.get(0) : String.format("%s\\%s", nodePath, path.get(0));
}
if (node.getChildren().isEmpty() && path.size() == 1) {
node.addChild(new Node(nodePath));
} else if (!node.getChildren().isEmpty()) {
for (Node actual : node.getChildren()) {
if (actual.getName().equals(path.get(0))) {
addNode(actual, path.subList(1, path.size()), nodePath);
return;
}
}
node.addChild(new Node(nodePath));
} else {
log.info("Without children but with size: " + path.size());
}
}
}

Categories