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

package com.abstratt.mdd.frontend.textuml.grammar.node;

import com.abstratt.mdd.frontend.textuml.grammar.analysis.*;

@SuppressWarnings("nls")
public final class AOptionalSubsetting extends POptionalSubsetting
{
    private TSubsets _subsets_;
    private PQualifiedIdentifier _qualifiedIdentifier_;

    public AOptionalSubsetting()
    {
        // Constructor
    }

    public AOptionalSubsetting(
        @SuppressWarnings("hiding") TSubsets _subsets_,
        @SuppressWarnings("hiding") PQualifiedIdentifier _qualifiedIdentifier_)
    {
        // Constructor
        setSubsets(_subsets_);

        setQualifiedIdentifier(_qualifiedIdentifier_);

    }

    @Override
    public Object clone()
    {
        return new AOptionalSubsetting(
            cloneNode(this._subsets_),
            cloneNode(this._qualifiedIdentifier_));
    }

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

    public TSubsets getSubsets()
    {
        return this._subsets_;
    }

    public void setSubsets(TSubsets node)
    {
        if(this._subsets_ != null)
        {
            this._subsets_.parent(null);
        }

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

            node.parent(this);
        }

        this._subsets_ = node;
    }

    public PQualifiedIdentifier getQualifiedIdentifier()
    {
        return this._qualifiedIdentifier_;
    }

    public void setQualifiedIdentifier(PQualifiedIdentifier node)
    {
        if(this._qualifiedIdentifier_ != null)
        {
            this._qualifiedIdentifier_.parent(null);
        }

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

            node.parent(this);
        }

        this._qualifiedIdentifier_ = node;
    }

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

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

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

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

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

        if(this._qualifiedIdentifier_ == oldChild)
        {
            setQualifiedIdentifier((PQualifiedIdentifier) newChild);
            return;
        }

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