diff options
| author | Michael Williamson <mike@zwobble.org> | 2015-10-25 18:16:35 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2015-10-25 18:16:35 +0000 |
| commit | d86042ef32735a78ea68e4312b34ed032b336c86 (patch) | |
| tree | a635cc6e873a72a58e3b43695a45c7b0294493bd | |
| parent | d1007c535bee905c910a361d0c6e6f00b32a0b3b (diff) | |
Remove lombok from LiteralNode
| -rw-r--r-- | src/main/java/org/zwobble/couscous/ast/LiteralNode.java | 60 | ||||
| -rw-r--r-- | src/test/java/org/zwobble/couscous/tests/ValueObjectTests.java | 1 |
2 files changed, 56 insertions, 5 deletions
diff --git a/src/main/java/org/zwobble/couscous/ast/LiteralNode.java b/src/main/java/org/zwobble/couscous/ast/LiteralNode.java index cd92291..ca005de 100644 --- a/src/main/java/org/zwobble/couscous/ast/LiteralNode.java +++ b/src/main/java/org/zwobble/couscous/ast/LiteralNode.java @@ -8,9 +8,6 @@ import org.zwobble.couscous.values.StringValue; import static org.zwobble.couscous.values.PrimitiveValues.value; -import lombok.Value; - -@Value(staticConstructor="of") public class LiteralNode implements ExpressionNode { public static LiteralNode literal(PrimitiveValue value) { return new LiteralNode(value, value.getType()); @@ -28,11 +25,64 @@ public class LiteralNode implements ExpressionNode { return new LiteralNode(value(value), BooleanValue.REF); } - PrimitiveValue value; - TypeName type; + public static LiteralNode of(PrimitiveValue value, TypeName type) { + return new LiteralNode(value, type); + } + + private final PrimitiveValue value; + private final TypeName type; + private LiteralNode(PrimitiveValue value, TypeName type) { + this.value = value; + this.type = type; + } + + public TypeName getType() { + return type; + } + + public PrimitiveValue getValue() { + return value; + } + @Override public <T> T accept(ExpressionNodeMapper<T> visitor) { return visitor.visit(this); } + + @Override + public String toString() { + return "LiteralNode(value=" + value + ", type=" + type + ")"; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((type == null) ? 0 : type.hashCode()); + result = prime * result + ((value == null) ? 0 : value.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + LiteralNode other = (LiteralNode) obj; + if (type == null) { + if (other.type != null) + return false; + } else if (!type.equals(other.type)) + return false; + if (value == null) { + if (other.value != null) + return false; + } else if (!value.equals(other.value)) + return false; + return true; + } } diff --git a/src/test/java/org/zwobble/couscous/tests/ValueObjectTests.java b/src/test/java/org/zwobble/couscous/tests/ValueObjectTests.java index 2837b47..9a32921 100644 --- a/src/test/java/org/zwobble/couscous/tests/ValueObjectTests.java +++ b/src/test/java/org/zwobble/couscous/tests/ValueObjectTests.java @@ -57,6 +57,7 @@ public class ValueObjectTests { {FieldAccessNode.class}, {FieldDeclarationNode.class}, {FormalArgumentNode.class}, + {LiteralNode.class}, {VariableDeclaration.class} }); } |
