From c8ae1ec096f5d1ac6db4f3a0035f7da106444e4e Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Sun, 3 Apr 2016 17:45:05 -0400 Subject: General code refactoring and maintenance --- .../java/bjc/dicelang/ast/LiteralDiceNode.java | 60 +++++++++++++++++++--- 1 file changed, 53 insertions(+), 7 deletions(-) (limited to 'dice-lang/src/main/java/bjc/dicelang/ast/LiteralDiceNode.java') diff --git a/dice-lang/src/main/java/bjc/dicelang/ast/LiteralDiceNode.java b/dice-lang/src/main/java/bjc/dicelang/ast/LiteralDiceNode.java index 8157844..b80f1a4 100644 --- a/dice-lang/src/main/java/bjc/dicelang/ast/LiteralDiceNode.java +++ b/dice-lang/src/main/java/bjc/dicelang/ast/LiteralDiceNode.java @@ -10,7 +10,7 @@ public class LiteralDiceNode implements IDiceASTNode { /** * The value contained by this node */ - private String data; + private String value; /** * Create a new node with the given value @@ -19,12 +19,35 @@ public class LiteralDiceNode implements IDiceASTNode { * The value to be in this node */ public LiteralDiceNode(String data) { - this.data = data; + this.value = data; } + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ @Override - public boolean isOperator() { - return false; + public boolean equals(Object obj) { + if (this == obj) { + return true; + } else if (obj == null) { + return false; + } else if (getClass() != obj.getClass()) { + return false; + } else { + LiteralDiceNode other = (LiteralDiceNode) obj; + + if (value == null) { + if (other.value != null) { + return false; + } + } else if (!value.equals(other.value)) { + return false; + } + + return true; + } } /** @@ -33,7 +56,30 @@ public class LiteralDiceNode implements IDiceASTNode { * @return the data stored in this AST node */ public String getData() { - return data; + return value; + } + + @Override + public DiceASTType getType() { + return DiceASTType.LITERAL; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((value == null) ? 0 : value.hashCode()); + return result; + } + + @Override + public boolean isOperator() { + return false; } /* @@ -43,6 +89,6 @@ public class LiteralDiceNode implements IDiceASTNode { */ @Override public String toString() { - return data; + return value; } -} +} \ No newline at end of file -- cgit v1.2.3