package de.ugoe.cs.quest.tasktrees.treeimpl;

import de.ugoe.cs.quest.tasktrees.treeifc.IIteration;
import de.ugoe.cs.quest.tasktrees.treeifc.ITaskTreeNode;

/**
 * TODO comment
 * 
 * @version $Revision: $ $Date: 19.02.2012$
 * @author 2012, last modified by $Author: patrick$
 */
public class Iteration extends TaskTreeNode implements IIteration {

    /**
     *
     */
    Iteration() {
        super("Iteration");
    }

    /*
     * (non-Javadoc)
     * 
     * @see de.ugoe.cs.tasktree.treeifc.TaskTreeNode#addChild(TaskTreeNode)
     */
    @Override
    public void addChild(ITaskTreeNode child) {
        // adding more children is not allowed
        throw new UnsupportedOperationException
          ("iterations may not have a list of children. Use setChild() instead.");
    }

    /**
     * TODO: comment
     * 
     * @param selection
     * @return
     */
    public void setChild(ITaskTreeNode child) {
        if (super.getChildren().size() > 0) {
            super.removeChild(0);
        }
        super.addChild(child);
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#clone()
     */
    @Override
    public Iteration clone() {
        return (Iteration) super.clone();
    }

}
