diff options
Diffstat (limited to 'src/main/java/org/zwobble/couscous/ast/ExceptionHandlerNode.java')
| -rw-r--r-- | src/main/java/org/zwobble/couscous/ast/ExceptionHandlerNode.java | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/main/java/org/zwobble/couscous/ast/ExceptionHandlerNode.java b/src/main/java/org/zwobble/couscous/ast/ExceptionHandlerNode.java new file mode 100644 index 0000000..a7e307b --- /dev/null +++ b/src/main/java/org/zwobble/couscous/ast/ExceptionHandlerNode.java @@ -0,0 +1,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; + } +} |
