// Autogenerated AST node
package org.python.pydev.parser.jython.ast;

import org.python.pydev.parser.jython.SimpleNode;
import java.util.Arrays;

public final class Raise extends stmtType {
    public exprType type;
    public exprType inst;
    public exprType tback;
    public exprType cause;

    public Raise(exprType type, exprType inst, exprType tback, exprType cause) {
        this.type = type;
        this.inst = inst;
        this.tback = tback;
        this.cause = cause;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((type == null) ? 0 : type.hashCode());
        result = prime * result + ((inst == null) ? 0 : inst.hashCode());
        result = prime * result + ((tback == null) ? 0 : tback.hashCode());
        result = prime * result + ((cause == null) ? 0 : cause.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Raise other = (Raise) obj;
        if (type == null) {
            if (other.type != null)
                return false;
        } else if (!type.equals(other.type))
            return false;
        if (inst == null) {
            if (other.inst != null)
                return false;
        } else if (!inst.equals(other.inst))
            return false;
        if (tback == null) {
            if (other.tback != null)
                return false;
        } else if (!tback.equals(other.tback))
            return false;
        if (cause == null) {
            if (other.cause != null)
                return false;
        } else if (!cause.equals(other.cause))
            return false;
        return true;
    }

    @Override
    public Raise createCopy() {
        return createCopy(true);
    }

    @Override
    public Raise createCopy(boolean copyComments) {
        Raise temp = new Raise(type != null ? (exprType) type.createCopy(copyComments) : null,
                inst != null ? (exprType) inst.createCopy(copyComments) : null,
                tback != null ? (exprType) tback.createCopy(copyComments) : null,
                cause != null ? (exprType) cause.createCopy(copyComments) : null);
        temp.beginLine = this.beginLine;
        temp.beginColumn = this.beginColumn;
        if (this.specialsBefore != null && copyComments) {
            for (Object o : this.specialsBefore) {
                if (o instanceof commentType) {
                    commentType commentType = (commentType) o;
                    temp.getSpecialsBefore().add(commentType.createCopy(copyComments));
                }
            }
        }
        if (this.specialsAfter != null && copyComments) {
            for (Object o : this.specialsAfter) {
                if (o instanceof commentType) {
                    commentType commentType = (commentType) o;
                    temp.getSpecialsAfter().add(commentType.createCopy(copyComments));
                }
            }
        }
        return temp;
    }

    @Override
    public String toString() {
        StringBuffer sb = new StringBuffer("Raise[");
        sb.append("type=");
        sb.append(dumpThis(this.type));
        sb.append(", ");
        sb.append("inst=");
        sb.append(dumpThis(this.inst));
        sb.append(", ");
        sb.append("tback=");
        sb.append(dumpThis(this.tback));
        sb.append(", ");
        sb.append("cause=");
        sb.append(dumpThis(this.cause));
        sb.append("]");
        return sb.toString();
    }

    @Override
    public Object accept(VisitorIF visitor) throws Exception {
        return visitor.visitRaise(this);
    }

    @Override
    public void traverse(VisitorIF visitor) throws Exception {
        if (type != null) {
            type.accept(visitor);
        }
        if (inst != null) {
            inst.accept(visitor);
        }
        if (tback != null) {
            tback.accept(visitor);
        }
        if (cause != null) {
            cause.accept(visitor);
        }
    }

}
