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

package se.sics.kola.node;

import java.util.*;
import se.sics.kola.analysis.*;

@SuppressWarnings("nls")
public final class AInterfaceBody extends PInterfaceBody
{
    private final LinkedList<PInterfaceMemberDeclaration> _interfaceMemberDeclaration_ = new LinkedList<PInterfaceMemberDeclaration>();

    public AInterfaceBody()
    {
        // Constructor
    }

    public AInterfaceBody(
        @SuppressWarnings("hiding") List<?> _interfaceMemberDeclaration_)
    {
        // Constructor
        setInterfaceMemberDeclaration(_interfaceMemberDeclaration_);

    }

    @Override
    public Object clone()
    {
        return new AInterfaceBody(
            cloneList(this._interfaceMemberDeclaration_));
    }

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

    public LinkedList<PInterfaceMemberDeclaration> getInterfaceMemberDeclaration()
    {
        return this._interfaceMemberDeclaration_;
    }

    public void setInterfaceMemberDeclaration(List<?> list)
    {
        for(PInterfaceMemberDeclaration e : this._interfaceMemberDeclaration_)
        {
            e.parent(null);
        }
        this._interfaceMemberDeclaration_.clear();

        for(Object obj_e : list)
        {
            PInterfaceMemberDeclaration e = (PInterfaceMemberDeclaration) obj_e;
            if(e.parent() != null)
            {
                e.parent().removeChild(e);
            }

            e.parent(this);
            this._interfaceMemberDeclaration_.add(e);
        }
    }

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

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

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

    @Override
    void replaceChild(@SuppressWarnings("unused") Node oldChild, @SuppressWarnings("unused") Node newChild)
    {
        // Replace child
        for(ListIterator<PInterfaceMemberDeclaration> i = this._interfaceMemberDeclaration_.listIterator(); i.hasNext();)
        {
            if(i.next() == oldChild)
            {
                if(newChild != null)
                {
                    i.set((PInterfaceMemberDeclaration) newChild);
                    newChild.parent(this);
                    oldChild.parent(null);
                    return;
                }

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

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