package boa.graphs.cdg;

import boa.graphs.cfg.CFGNode;

import java.util.ArrayList;
import java.util.List;

public class TreeNode implements Comparable<TreeNode> {

    private TreeNode parent;
    private int id;
    private CFGNode node;
    private List<TreeNode> children = new ArrayList<>();

    public TreeNode(CFGNode node) {
        this.id = node.getId();
        this.node = node;
    }

    //Getters
    public TreeNode getParent() {
        return parent;
    }

    public int getId() {
        return id;
    }

    public CFGNode getNode() {
        return node;
    }

    public List<TreeNode> getChildren() {
        return children;
    }

    //Setters
    public void setParent(TreeNode parent) {
        this.parent = parent;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Override
    public int compareTo(final TreeNode node) {
        return node.id - this.id;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        TreeNode treeNode = (TreeNode) o;

        return id == treeNode.id;
    }

    @Override
    public int hashCode() {
        return id;
    }
}
@@ -18,16 +18,40 @@
 s.cdg;%0A%0A
+import boa.types.Ast.*;%0A
 import b
@@ -95,40 +95,9 @@
 til.
-ArrayList;%0Aimport java.util.List
+*
 ;%0A%0Ap
@@ -217,21 +217,77 @@
 ate 
-CFGNode node;
+String pid;%0A    private Statement stmt;%0A    private Expression expr;%0A
 %0A   
@@ -426,19 +426,158 @@
 his.
-node = node
+pid = node.getPid();%0A        this.stmt = node.getStmt();%0A        this.expr = node.getExpr();%0A    %7D%0A%0A    public TreeNode(int id) %7B%0A        this.id = id
 ;%0A  
@@ -587,17 +587,17 @@
 %0A%0A    //
-G
+S
 etters%0A 
@@ -598,32 +598,47 @@
 ters%0A    public 
+void setParent(
 TreeNode getPare
@@ -634,18 +634,14 @@
 ode 
-getP
+p
 arent
-(
 ) %7B%0A
@@ -648,22 +648,29 @@
         
-return
+this.parent =
  parent;
@@ -692,18 +692,25 @@
 lic 
-int getId(
+void setId(int id
 ) %7B%0A
@@ -709,38 +709,41 @@
 t id) %7B%0A        
-return
+this.id =
  id;%0A    %7D%0A%0A    
@@ -753,121 +753,207 @@
 lic 
-CFGNode getNode() %7B%0A        return node;%0A    %7D%0A%0A    public List%3CTreeNode%3E getChildren() %7B%0A        return children
+void setPid(String pid) %7B%0A        this.pid = pid;%0A    %7D%0A%0A    public void setStmt(Statement stmt) %7B%0A        this.stmt = stmt;%0A    %7D%0A%0A    public void setExpr(Expression expr) %7B%0A        this.expr = expr
 ;%0A  
@@ -955,33 +955,33 @@
 r;%0A    %7D%0A%0A    //
-S
+G
 etters%0A    publi
@@ -986,131 +986,356 @@
 lic 
-void setParent(TreeNode parent) %7B%0A        this.parent = parent;%0A    %7D%0A%0A    public void setId(int id) %7B%0A        this.id = id
+TreeNode getParent() %7B%0A        return parent;%0A    %7D%0A%0A    public int getId() %7B%0A        return id;%0A    %7D%0A%0A    public String getPid() %7B%0A        return pid;%0A    %7D%0A%0A    public Statement getStmt() %7B%0A        return stmt;%0A    %7D%0A%0A    public Expression getExpr() %7B%0A        return expr;%0A    %7D%0A%0A    public List%3CTreeNode%3E getChildren() %7B%0A        return children
 ;%0A  
@@ -1482,16 +1482,22 @@
  equals(
+final 
 Object o

add more fields from cfg node