aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/zwobble/couscous/ast/ExceptionHandlerNode.java
blob: a7e307b0ac22acacfb24c09cbe8c9bb615152643 (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
package org.zwobble.couscous.ast;

import org.zwobble.couscous.types.Type;

import java.util.List;

public class ExceptionHandlerNode {
    public static ExceptionHandlerNode exceptionhandler(Type type, List<StatementNode> body) {
        return new ExceptionHandlerNode(type, body);
    }

    private final Type type;
    private final List<StatementNode> body;

    public ExceptionHandlerNode(Type type, List<StatementNode> body) {
        this.type = type;
        this.body = body;
    }

    public Type getExceptionType() {
        return type;
    }

    public List<StatementNode> getBody() {
        return body;
    }

    @Override
    public String toString() {
        return "ExceptionHandlerNode(" +
            "type=" + type +
            ", body=" + body +
            ')';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        ExceptionHandlerNode that = (ExceptionHandlerNode) o;

        if (!type.equals(that.type)) return false;
        return body.equals(that.body);

    }

    @Override
    public int hashCode() {
        int result = type.hashCode();
        result = 31 * result + body.hashCode();
        return result;
    }
}