/* This file was generated by SableCC (http://www.sablecc.org/). */

package soot.jimple.parser.node;

import soot.jimple.parser.analysis.*;

@SuppressWarnings("nls")
public final class AInstanceofExpression extends PExpression
{
    private PImmediate _immediate_;
    private TInstanceof _instanceof_;
    private PNonvoidType _nonvoidType_;

    public AInstanceofExpression()
    {
        // Constructor
    }

    public AInstanceofExpression(
        @SuppressWarnings("hiding") PImmediate _immediate_,
        @SuppressWarnings("hiding") TInstanceof _instanceof_,
        @SuppressWarnings("hiding") PNonvoidType _nonvoidType_)
    {
        // Constructor
        setImmediate(_immediate_);

        setInstanceof(_instanceof_);

        setNonvoidType(_nonvoidType_);

    }

    @Override
    public Object clone()
    {
        return new AInstanceofExpression(
            cloneNode(this._immediate_),
            cloneNode(this._instanceof_),
            cloneNode(this._nonvoidType_));
    }

    @Override
    public void apply(Switch sw)
    {
        ((Analysis) sw).caseAInstanceofExpression(this);
    }

    public PImmediate getImmediate()
    {
        return this._immediate_;
    }

    public void setImmediate(PImmediate node)
    {
        if(this._immediate_ != null)
        {
            this._immediate_.parent(null);
        }

        if(node != null)
        {
            if(node.parent() != null)
            {
                node.parent().removeChild(node);
            }

            node.parent(this);
        }

        this._immediate_ = node;
    }

    public TInstanceof getInstanceof()
    {
        return this._instanceof_;
    }

    public void setInstanceof(TInstanceof node)
    {
        if(this._instanceof_ != null)
        {
            this._instanceof_.parent(null);
        }

        if(node != null)
        {
            if(node.parent() != null)
            {
                node.parent().removeChild(node);
            }

            node.parent(this);
        }

        this._instanceof_ = node;
    }

    public PNonvoidType getNonvoidType()
    {
        return this._nonvoidType_;
    }

    public void setNonvoidType(PNonvoidType node)
    {
        if(this._nonvoidType_ != null)
        {
            this._nonvoidType_.parent(null);
        }

        if(node != null)
        {
            if(node.parent() != null)
            {
                node.parent().removeChild(node);
            }

            node.parent(this);
        }

        this._nonvoidType_ = node;
    }

    @Override
    public String toString()
    {
        return ""
            + toString(this._immediate_)
            + toString(this._instanceof_)
            + toString(this._nonvoidType_);
    }

    @Override
    void removeChild(@SuppressWarnings("unused") Node child)
    {
        // Remove child
        if(this._immediate_ == child)
        {
            this._immediate_ = null;
            return;
        }

        if(this._instanceof_ == child)
        {
            this._instanceof_ = null;
            return;
        }

        if(this._nonvoidType_ == child)
        {
            this._nonvoidType_ = null;
            return;
        }

        throw new RuntimeException("Not a child.");
    }

    @Override
    void replaceChild(@SuppressWarnings("unused") Node oldChild, @SuppressWarnings("unused") Node newChild)
    {
        // Replace child
        if(this._immediate_ == oldChild)
        {
            setImmediate((PImmediate) newChild);
            return;
        }

        if(this._instanceof_ == oldChild)
        {
            setInstanceof((TInstanceof) newChild);
            return;
        }

        if(this._nonvoidType_ == oldChild)
        {
            setNonvoidType((PNonvoidType) newChild);
            return;
        }

        throw new RuntimeException("Not a child.");
    }
}
