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

package MONAViewer.monalanguage.node;

import java.util.*;
import MONAViewer.monalanguage.analysis.*;

public final class AGuideDeclaration extends PDeclaration
{
    private final LinkedList _func_ = new TypedLinkedList(new Func_Cast());

    public AGuideDeclaration ()
    {
    }

    public AGuideDeclaration (
            List _func_
    )
    {
        this._func_.clear();
        this._func_.addAll(_func_);
    }

    public Object clone()
    {
        return new AGuideDeclaration (
            cloneList (_func_)
        );
    }

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

    public LinkedList getFunc ()
    {
        return _func_;
    }

    public void setFunc (List list)
    {
        _func_.clear();
        _func_.addAll(list);
    }

    public String toString()
    {
        return ""
            + toString (_func_)
        ;
    }

    void removeChild(Node child)
    {
        if ( _func_.remove(child))
        {
            return;
        }
    }

    void replaceChild(Node oldChild, Node newChild)
    {
        for(ListIterator i = _func_.listIterator(); i.hasNext();)
        {
            if(i.next() == oldChild)
            {
                if(newChild != null)
                {
                    i.set(newChild);
                    oldChild.parent(null);
                    return;
                }

                i.remove();
                oldChild.parent(null);
                return;
            }
        }
    }

    private class Func_Cast implements Cast
    {
        public Object cast(Object o)
        {
            PFunc node = (PFunc) o;

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

            if((node.parent() == null) ||
                (node.parent() != AGuideDeclaration.this))
            {
                node.parent(AGuideDeclaration.this);
            }

            return node;
        }
    }
}
