/* ----------------------------------------
 * Origin  : GFI INFORMATIQUE 
 * Project : CDPP Propagation Tool 
 * ----------------------------------------
 * History 
 * Version : 01/05/2015 : SCA : V2.1
 * ----------------------------------------
 */
package fr.tlse.irap.pt.client.controller.common;

import java.util.ArrayList;
import java.util.List;

import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlType;

@XmlType
public class Item {

	private String name;
	private List<Item> childs;

	public Item() {
		childs = new ArrayList<Item>();
	}

	public Item(String n) {
		this();
		this.name = n;
	}

	public String getName() {
		return name;
	}

	public void setName(String n) {
		this.name = n;
	}

	@XmlElement
	public List<Item> getChild() {
		return childs;
	}

	public void addAll(List<Item> asList) {
		childs.addAll(asList);
	}

	public void add(Item item) {
		childs.add(item);
	}

	/**
	 * if childs are null or empty then the item has no child.
	 * 
	 * @return
	 */
	public boolean hasChild() {
		return (childs == null) ? false : (!childs.isEmpty());
	}

}
