aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/zwobble/couscous/ast/StaticMethodCallNode.java83
-rw-r--r--src/test/java/org/zwobble/couscous/tests/ValueObjectTests.java2
2 files changed, 79 insertions, 6 deletions
diff --git a/src/main/java/org/zwobble/couscous/ast/StaticMethodCallNode.java b/src/main/java/org/zwobble/couscous/ast/StaticMethodCallNode.java
index e0566cf..2b63948 100644
--- a/src/main/java/org/zwobble/couscous/ast/StaticMethodCallNode.java
+++ b/src/main/java/org/zwobble/couscous/ast/StaticMethodCallNode.java
@@ -6,9 +6,6 @@ import org.zwobble.couscous.ast.visitors.ExpressionNodeMapper;
import static java.util.Arrays.asList;
-import lombok.Value;
-
-@Value(staticConstructor="staticMethodCall")
public class StaticMethodCallNode implements ExpressionNode {
public static StaticMethodCallNode staticMethodCall(String className, String methodName, ExpressionNode... arguments) {
return staticMethodCall(className, methodName, asList(arguments));
@@ -18,9 +15,37 @@ public class StaticMethodCallNode implements ExpressionNode {
return staticMethodCall(TypeName.of(className), methodName, arguments);
}
- TypeName className;
- String methodName;
- List<ExpressionNode> arguments;
+ public static StaticMethodCallNode staticMethodCall(
+ TypeName className,
+ String methodName,
+ List<ExpressionNode> arguments) {
+ return new StaticMethodCallNode(className, methodName, arguments);
+ }
+
+ private final TypeName className;
+ private final String methodName;
+ private final List<ExpressionNode> arguments;
+
+ public StaticMethodCallNode(
+ TypeName className,
+ String methodName,
+ List<ExpressionNode> arguments) {
+ this.className = className;
+ this.methodName = methodName;
+ this.arguments = arguments;
+ }
+
+ public TypeName getClassName() {
+ return className;
+ }
+
+ public String getMethodName() {
+ return methodName;
+ }
+
+ public List<ExpressionNode> getArguments() {
+ return arguments;
+ }
@Override
public <T> T accept(ExpressionNodeMapper<T> visitor) {
@@ -31,4 +56,50 @@ public class StaticMethodCallNode implements ExpressionNode {
public TypeName getType() {
throw new UnsupportedOperationException();
}
+
+ @Override
+ public String toString() {
+ return "StaticMethodCallNode(className=" + className + ", methodName="
+ + methodName + ", arguments=" + arguments + ")";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((arguments == null) ? 0 : arguments.hashCode());
+ result = prime * result
+ + ((className == null) ? 0 : className.hashCode());
+ result = prime * result
+ + ((methodName == null) ? 0 : methodName.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;
+ StaticMethodCallNode other = (StaticMethodCallNode) obj;
+ if (arguments == null) {
+ if (other.arguments != null)
+ return false;
+ } else if (!arguments.equals(other.arguments))
+ return false;
+ if (className == null) {
+ if (other.className != null)
+ return false;
+ } else if (!className.equals(other.className))
+ return false;
+ if (methodName == null) {
+ if (other.methodName != null)
+ return false;
+ } else if (!methodName.equals(other.methodName))
+ 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 b19d9f1..8fb28ec 100644
--- a/src/test/java/org/zwobble/couscous/tests/ValueObjectTests.java
+++ b/src/test/java/org/zwobble/couscous/tests/ValueObjectTests.java
@@ -27,6 +27,7 @@ import org.zwobble.couscous.ast.LiteralNode;
import org.zwobble.couscous.ast.LocalVariableDeclarationNode;
import org.zwobble.couscous.ast.MethodCallNode;
import org.zwobble.couscous.ast.ReturnNode;
+import org.zwobble.couscous.ast.StaticMethodCallNode;
import org.zwobble.couscous.ast.VariableDeclaration;
import org.zwobble.couscous.ast.VariableReferenceNode;
import org.zwobble.couscous.util.ExtraArrays;
@@ -64,6 +65,7 @@ public class ValueObjectTests {
{LocalVariableDeclarationNode.class},
{MethodCallNode.class},
{ReturnNode.class},
+ {StaticMethodCallNode.class},
{VariableDeclaration.class}
});
}