hashcode
This commit is contained in:
@ -1,5 +1,7 @@
|
|||||||
package util.ast;
|
package util.ast;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class AST {
|
public class AST {
|
||||||
|
|
||||||
private final Node root;
|
private final Node root;
|
||||||
@ -25,4 +27,9 @@ public class AST {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return this.root.toString();
|
return this.root.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(this.root);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package util.ast;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class Node {
|
public class Node {
|
||||||
|
|
||||||
@ -15,11 +16,6 @@ public class Node {
|
|||||||
this.value = "";
|
this.value = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public Node(String name, String value) {
|
|
||||||
this.name = name;
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addChild(Node node) {
|
public void addChild(Node node) {
|
||||||
this.children.add(node);
|
this.children.add(node);
|
||||||
}
|
}
|
||||||
@ -28,6 +24,10 @@ public class Node {
|
|||||||
return !this.children.isEmpty();
|
return !this.children.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Node> getChildren() {
|
||||||
|
return this.children;
|
||||||
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
@ -77,4 +77,9 @@ public class Node {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(this.name, this.value, this.children); // TODO: children?
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user