All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ars.database.model.AbstractTreeModel Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
package ars.database.model;

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

import ars.util.Trees;
import ars.database.model.TreeModel;
import ars.database.model.AbstractModel;

/**
 * 树形数据模型抽象实现
 * 
 * @author yongqiangwu
 * 
 * @param 
 *            树对象类型
 */
public abstract class AbstractTreeModel> extends
		AbstractModel implements TreeModel {
	private static final long serialVersionUID = 1L;

	private String key; // 树标识
	private Integer level = 1; // 所在树中的层级(从1开始)
	private Boolean leaf = true; // 是否是叶节点
	private T parent; // 父节点
	private List children = new ArrayList(0); // 子节点

	@Override
	public String getKey() {
		return key;
	}

	@Override
	public void setKey(String key) {
		this.key = key;
	}

	@Override
	public Integer getLevel() {
		return level;
	}

	@Override
	public void setLevel(Integer level) {
		this.level = level;
	}

	@Override
	public Boolean getLeaf() {
		return leaf;
	}

	@Override
	public void setLeaf(Boolean leaf) {
		this.leaf = leaf;
	}

	@Override
	public T getParent() {
		return parent;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List getParents() {
		return (List) Trees.getParents(this);
	}

	@Override
	public void setParent(T parent) {
		this.parent = parent;
	}

	@Override
	public List getChildren() {
		return children;
	}

	@Override
	public void setChildren(List children) {
		this.children = children;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy