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

package node;

import analysis.*;

@SuppressWarnings("nls")
public final class AParPrimary extends PPrimary
{
    private TLpar _lpar_;
    private PAdditive _additive_;
    private TRpar _rpar_;

    public AParPrimary()
    {
        // Constructor
    }

    public AParPrimary(
        @SuppressWarnings("hiding") TLpar _lpar_,
        @SuppressWarnings("hiding") PAdditive _additive_,
        @SuppressWarnings("hiding") TRpar _rpar_)
    {
        // Constructor
        setLpar(_lpar_);

        setAdditive(_additive_);

        setRpar(_rpar_);

    }

    @Override
    public Object clone()
    {
        return new AParPrimary(
            cloneNode(this._lpar_),
            cloneNode(this._additive_),
            cloneNode(this._rpar_));
    }

    public void apply(Switch sw)
    {
        ((Analysis) sw).caseAParPrimary(this);
    }

    public TLpar getLpar()
    {
        return this._lpar_;
    }

    public void setLpar(TLpar node)
    {
        if(this._lpar_ != null)
        {
            this._lpar_.parent(null);
        }

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

            node.parent(this);
        }

        this._lpar_ = node;
    }

    public PAdditive getAdditive()
    {
        return this._additive_;
    }

    public void setAdditive(PAdditive node)
    {
        if(this._additive_ != null)
        {
            this._additive_.parent(null);
        }

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

            node.parent(this);
        }

        this._additive_ = node;
    }

    public TRpar getRpar()
    {
        return this._rpar_;
    }

    public void setRpar(TRpar node)
    {
        if(this._rpar_ != null)
        {
            this._rpar_.parent(null);
        }

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

            node.parent(this);
        }

        this._rpar_ = node;
    }

    @Override
    public String toString()
    {
        return ""
            + toString(this._lpar_)
            + toString(this._additive_)
            + toString(this._rpar_);
    }

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

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

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

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

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

        if(this._additive_ == oldChild)
        {
            setAdditive((PAdditive) newChild);
            return;
        }

        if(this._rpar_ == oldChild)
        {
            setRpar((TRpar) newChild);
            return;
        }

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