diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-04-03 17:45:05 -0400 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-04-03 17:45:05 -0400 |
| commit | c8ae1ec096f5d1ac6db4f3a0035f7da106444e4e (patch) | |
| tree | 6c32c65d84d11efcea2bad699d0b68fbbb362290 /dice-lang/src/main/java/bjc/dicelang/ast/LiteralDiceNode.java | |
| parent | 9a6ac8c88689073cd0769da15b40c4fe091f0813 (diff) | |
General code refactoring and maintenance
Diffstat (limited to 'dice-lang/src/main/java/bjc/dicelang/ast/LiteralDiceNode.java')
| -rw-r--r-- | dice-lang/src/main/java/bjc/dicelang/ast/LiteralDiceNode.java | 60 |
1 files changed, 53 insertions, 7 deletions
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 |
