/**
 * Created on Jun 18, 2005
 * $id:  $
 */
package org.jvnet.lookout.ui.core.tree;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class TreeParent extends TreeObject implements Serializable {
    
    private List <TreeObject> children;

    public TreeParent() {
        this("");
    }
    
    public TreeParent(String name) {
        super(name);
        children = new ArrayList<TreeObject>();
    }

    public void addChild(TreeObject child) {
        children.add(child);
        child.setParent(this);
    }

    public void removeChild(TreeObject child) {
        children.remove(child);
        child.setParent(null);
    }

    public TreeObject[] getChildren() {
        return children.toArray(new TreeObject[children.size()]);
    }

    public boolean hasChildren() {
        return !children.isEmpty();
    }
    
    public void clear() {
        children.clear();
    }    
}
