aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/zwobble/couscous/ast/StaticReceiver.java
blob: 4d353763cc1e160270a715393be6369c9b4faf25 (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
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();
    }
}