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

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

public final class AugAssign extends stmtType implements operatorType {
    public exprType target;
    public int op;
    public exprType value;

    public AugAssign(exprType target, int op, exprType value) {
        this.target = target;
        this.op = op;
        this.value = value;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((target == null) ? 0 : target.hashCode());
        result = prime * result + op;
        result = prime * result + ((value == null) ? 0 : value.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;
        AugAssign other = (AugAssign) obj;
        if (target == null) { if (other.target != null) return false;}
        else if (!target.equals(other.target)) return false;
        if(this.op != other.op) return false;
        if (value == null) { if (other.value != null) return false;}
        else if (!value.equals(other.value)) return false;
        return true;
    }
    @Override
    public AugAssign createCopy() {
        return createCopy(true);
    }
    @Override
    public AugAssign createCopy(boolean copyComments) {
        AugAssign temp = new AugAssign(target!=null?(exprType)target.createCopy(copyComments):null,
        op, value!=null?(exprType)value.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("AugAssign[");
        sb.append("target=");
        sb.append(dumpThis(this.target));
        sb.append(", ");
        sb.append("op=");
        sb.append(dumpThis(this.op, operatorType.operatorTypeNames));
        sb.append(", ");
        sb.append("value=");
        sb.append(dumpThis(this.value));
        sb.append("]");
        return sb.toString();
    }

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

    @Override
    public void traverse(VisitorIF visitor) throws Exception {
        if (target != null) {
            target.accept(visitor);
        }
        if (value != null) {
            value.accept(visitor);
        }
    }

}
