From d86042ef32735a78ea68e4312b34ed032b336c86 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sun, 25 Oct 2015 18:16:35 +0000 Subject: Remove lombok from LiteralNode --- .../java/org/zwobble/couscous/ast/LiteralNode.java | 60 ++++++++++++++++++++-- .../zwobble/couscous/tests/ValueObjectTests.java | 1 + 2 files changed, 56 insertions(+), 5 deletions(-) (limited to 'src') 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 accept(ExpressionNodeMapper 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} }); } -- cgit v1.2.3