blob: a61a685e0e8f80feb810f98f53c895e8e47a9e24 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
package org.zwobble.couscous.ast;
import org.zwobble.couscous.ast.visitors.NodeTransformer;
import org.zwobble.couscous.types.ScalarType;
import org.zwobble.couscous.util.ExtraIterables;
public class StaticReceiver implements Receiver {
public static Receiver staticReceiver(String type) {
return new StaticReceiver(ScalarType.topLevel(type));
}
public static Receiver staticReceiver(ScalarType type) {
return new StaticReceiver(type);
}
private final ScalarType type;
public StaticReceiver(ScalarType type) {
this.type = type;
}
public ScalarType getType() {
return type;
}
@Override
public <T> T accept(Mapper<T> mapper) {
return mapper.visit(type);
}
@Override
public int nodeType() {
return NodeTypes.STATIC_RECEIVER;
}
@Override
public Iterable<? extends Node> childNodes() {
return ExtraIterables.empty();
}
@Override
public Receiver transformSubtree(NodeTransformer transformer) {
return new StaticReceiver(transformer.transform(type));
}
@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();
}
}
|