diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-04-04 08:17:04 -0400 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2016-04-04 08:17:04 -0400 |
| commit | 12280e8f01b4f761c65bad11e5316cfc4655a431 (patch) | |
| tree | 5605eb9eb5982a26d4823a9c7ec4afbb8dcea0da /dice-lang/src/main/java/bjc/dicelang/ast/nodes/LiteralDiceNode.java | |
| parent | adea5713f3d6711885108e359813b4a62ffee98f (diff) | |
Moved nodes to new packages
Diffstat (limited to 'dice-lang/src/main/java/bjc/dicelang/ast/nodes/LiteralDiceNode.java')
| -rw-r--r-- | dice-lang/src/main/java/bjc/dicelang/ast/nodes/LiteralDiceNode.java | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/dice-lang/src/main/java/bjc/dicelang/ast/nodes/LiteralDiceNode.java b/dice-lang/src/main/java/bjc/dicelang/ast/nodes/LiteralDiceNode.java new file mode 100644 index 0000000..fe4c402 --- /dev/null +++ b/dice-lang/src/main/java/bjc/dicelang/ast/nodes/LiteralDiceNode.java @@ -0,0 +1,94 @@ +package bjc.dicelang.ast.nodes; + +/** + * A AST node that represents a literal value + * + * @author ben + * + */ +public class LiteralDiceNode implements IDiceASTNode { + /** + * The value contained by this node + */ + private String value; + + /** + * Create a new node with the given value + * + * @param data + * The value to be in this node + */ + public LiteralDiceNode(String data) { + this.value = data; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + 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; + } + } + + /** + * Get the data stored in this AST node + * + * @return the data stored in this AST node + */ + public String getData() { + 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; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return value; + } +}
\ No newline at end of file |
