aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2015-10-25 18:20:39 +0000
committerMichael Williamson <mike@zwobble.org>2015-10-25 18:20:39 +0000
commited9dcc150efe3df4884b6023a71c6c5216cc8e33 (patch)
tree278c591aaff5028f10e26adb5cf648ec954fbf6d /src
parentbf686485cebb7550ae9ddbbdbefa929aea9f8127 (diff)
Remove lombok from MethodCallNode
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/zwobble/couscous/ast/MethodCallNode.java93
-rw-r--r--src/test/java/org/zwobble/couscous/tests/ValueObjectTests.java2
2 files changed, 87 insertions, 8 deletions
diff --git a/src/main/java/org/zwobble/couscous/ast/MethodCallNode.java b/src/main/java/org/zwobble/couscous/ast/MethodCallNode.java
index aa81c6c..a9b8795 100644
--- a/src/main/java/org/zwobble/couscous/ast/MethodCallNode.java
+++ b/src/main/java/org/zwobble/couscous/ast/MethodCallNode.java
@@ -4,15 +4,7 @@ import java.util.List;
import org.zwobble.couscous.ast.visitors.ExpressionNodeMapper;
-import lombok.Value;
-
-@Value
public class MethodCallNode implements ExpressionNode {
- ExpressionNode receiver;
- String methodName;
- List<ExpressionNode> arguments;
- TypeName type;
-
public static MethodCallNode methodCall(
ExpressionNode receiver,
String methodName,
@@ -21,8 +13,93 @@ public class MethodCallNode implements ExpressionNode {
return new MethodCallNode(receiver, methodName, arguments, type);
}
+ private final ExpressionNode receiver;
+ private final String methodName;
+ private final List<ExpressionNode> arguments;
+ private final TypeName type;
+
+ public MethodCallNode(
+ ExpressionNode receiver,
+ String methodName,
+ List<ExpressionNode> arguments,
+ TypeName type) {
+ this.receiver = receiver;
+ this.methodName = methodName;
+ this.arguments = arguments;
+ this.type = type;
+ }
+
+ public ExpressionNode getReceiver() {
+ return receiver;
+ }
+
+ public String getMethodName() {
+ return methodName;
+ }
+
+ public List<ExpressionNode> getArguments() {
+ return arguments;
+ }
+
+ public TypeName getType() {
+ return type;
+ }
+
@Override
public <T> T accept(ExpressionNodeMapper<T> visitor) {
return visitor.visit(this);
}
+
+ @Override
+ public String toString() {
+ return "MethodCallNode(receiver=" + receiver + ", methodName="
+ + methodName + ", arguments=" + arguments + ", type=" + type
+ + ")";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((arguments == null) ? 0 : arguments.hashCode());
+ result = prime * result
+ + ((methodName == null) ? 0 : methodName.hashCode());
+ result = prime * result
+ + ((receiver == null) ? 0 : receiver.hashCode());
+ result = prime * result + ((type == null) ? 0 : type.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;
+ MethodCallNode other = (MethodCallNode) obj;
+ if (arguments == null) {
+ if (other.arguments != null)
+ return false;
+ } else if (!arguments.equals(other.arguments))
+ return false;
+ if (methodName == null) {
+ if (other.methodName != null)
+ return false;
+ } else if (!methodName.equals(other.methodName))
+ return false;
+ if (receiver == null) {
+ if (other.receiver != null)
+ return false;
+ } else if (!receiver.equals(other.receiver))
+ return false;
+ if (type == null) {
+ if (other.type != null)
+ return false;
+ } else if (!type.equals(other.type))
+ 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 347fef0..c018c26 100644
--- a/src/test/java/org/zwobble/couscous/tests/ValueObjectTests.java
+++ b/src/test/java/org/zwobble/couscous/tests/ValueObjectTests.java
@@ -25,6 +25,7 @@ import org.zwobble.couscous.ast.FieldDeclarationNode;
import org.zwobble.couscous.ast.FormalArgumentNode;
import org.zwobble.couscous.ast.LiteralNode;
import org.zwobble.couscous.ast.LocalVariableDeclarationNode;
+import org.zwobble.couscous.ast.MethodCallNode;
import org.zwobble.couscous.ast.VariableDeclaration;
import org.zwobble.couscous.ast.VariableReferenceNode;
import org.zwobble.couscous.util.ExtraArrays;
@@ -60,6 +61,7 @@ public class ValueObjectTests {
{FormalArgumentNode.class},
{LiteralNode.class},
{LocalVariableDeclarationNode.class},
+ {MethodCallNode.class},
{VariableDeclaration.class}
});
}