aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/zwobble/couscous/ast/StaticReceiver.java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-01-10 16:12:32 +0000
committerMichael Williamson <mike@zwobble.org>2016-01-10 16:12:32 +0000
commit1cca01d385e68aefe2131319c53c4811101f15f7 (patch)
tree08fbdf98f3e0d53ce1c64925bef8ad576c52ae64 /src/main/java/org/zwobble/couscous/ast/StaticReceiver.java
parent29c9a38a112b53e4ca193af27818442493c876cb (diff)
Handle both static and instance method calls in one node
Diffstat (limited to 'src/main/java/org/zwobble/couscous/ast/StaticReceiver.java')
-rw-r--r--src/main/java/org/zwobble/couscous/ast/StaticReceiver.java58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/main/java/org/zwobble/couscous/ast/StaticReceiver.java b/src/main/java/org/zwobble/couscous/ast/StaticReceiver.java
new file mode 100644
index 0000000..4d35376
--- /dev/null
+++ b/src/main/java/org/zwobble/couscous/ast/StaticReceiver.java
@@ -0,0 +1,58 @@
+package org.zwobble.couscous.ast;
+
+import org.zwobble.couscous.ast.visitors.NodeMapper;
+
+import java.util.function.Function;
+
+public class StaticReceiver implements Receiver {
+ public static Receiver staticReceiver(TypeName type) {
+ return new StaticReceiver(type);
+ }
+
+ private final TypeName type;
+
+ public StaticReceiver(TypeName type) {
+ this.type = type;
+ }
+
+ public TypeName getType() {
+ return type;
+ }
+
+ @Override
+ public Receiver replaceExpressions(Function<ExpressionNode, ExpressionNode> replace) {
+ return this;
+ }
+
+ @Override
+ public <T> T accept(Mapper<T> mapper) {
+ return mapper.visit(type);
+ }
+
+ @Override
+ public <T> T accept(NodeMapper<T> visitor) {
+ return visitor.visit(this);
+ }
+
+ @Override
+ public String toString() {
+ return "StaticReceiver(" +
+ "type=" + type +
+ ')';
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ StaticReceiver that = (StaticReceiver) o;
+
+ return type.equals(that.type);
+ }
+
+ @Override
+ public int hashCode() {
+ return type.hashCode();
+ }
+}