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

com.anysoft.tree.TreeNode Maven / Gradle / Ivy

There is a newer version: 1.6.17
Show newest version
package com.anysoft.tree;

/**
 * 树的节点
 * @author yyduan
 * @since 1.6.11.58 
 */
public interface TreeNode {
	/**
	 * 获取当前节点id
	 * @return 节点id
	 */
	public String getId();
	
	/**
	 * 获取父节点id
	 * @return 父节点id
	 */
	public String getParentId();
	
	/**
	 * 获取节点数据
	 * @return 节点数据对象
	 */
	public O getData();
	
	/**
	 * 缺省实现
	 * 
	 * @author yyduan
	 *
	 * @param 
	 */
	public static class Default implements TreeNode{
		protected String id;
		protected String parentId = "0";
		protected O data;
		
		public Default(String id,String parentId,O data){
			this.id = id;
			this.parentId = parentId;
			this.data = data;
		}
		
		public Default(String id,O data){
			this(id,"0",data);
		}
		
		@Override
		public String getId() {
			return id;
		}

		@Override
		public String getParentId() {
			return parentId;
		}

		@Override
		public O getData() {
			return data;
		}
		
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy