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

package se.sics.kola.node;

import se.sics.kola.analysis.*;

@SuppressWarnings("nls")
public final class ASynchronizedStatement extends PSynchronizedStatement
{
    private PExpression _lock_;
    private PBlock _block_;

    public ASynchronizedStatement()
    {
        // Constructor
    }

    public ASynchronizedStatement(
        @SuppressWarnings("hiding") PExpression _lock_,
        @SuppressWarnings("hiding") PBlock _block_)
    {
        // Constructor
        setLock(_lock_);

        setBlock(_block_);

    }

    @Override
    public Object clone()
    {
        return new ASynchronizedStatement(
            cloneNode(this._lock_),
            cloneNode(this._block_));
    }

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

    public PExpression getLock()
    {
        return this._lock_;
    }

    public void setLock(PExpression node)
    {
        if(this._lock_ != null)
        {
            this._lock_.parent(null);
        }

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

            node.parent(this);
        }

        this._lock_ = node;
    }

    public PBlock getBlock()
    {
        return this._block_;
    }

    public void setBlock(PBlock node)
    {
        if(this._block_ != null)
        {
            this._block_.parent(null);
        }

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

            node.parent(this);
        }

        this._block_ = node;
    }

    @Override
    public String toString()
    {
        return ""
            + toString(this._lock_)
            + toString(this._block_);
    }

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

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

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

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

        if(this._block_ == oldChild)
        {
            setBlock((PBlock) newChild);
            return;
        }

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