net.sf.mmm.util.collection.api
Interface TreeNode<NODE extends TreeNode<NODE>>

Type Parameters:
NODE - is the generic type for self-references. Each sub-type of this interface should specialize this type to itself. End-users should simply use an unbound wildcard (TreeNode<?>).
All Known Implementing Classes:
AbstractTreeNode

public interface TreeNode<NODE extends TreeNode<NODE>>

This is the interface for the node a tree. The tree itself is defined by the root-node which is its only node in the tree that has no parent.

Since:
1.0.2
Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)

Method Summary
 List<NODE> getChildren()
          This method gets the List containing all children of this TreeNode.
 NODE getParent()
          This method gets the parent of this TreeNode.
 boolean isAncestor(TreeNode<?> node)
          This method determines if this TreeNode is an ancestor of the given node.
 boolean isDescendant(TreeNode<?> node)
          This method determines if this TreeNode is a descendant of the given node.
 

Method Detail

getParent

NODE getParent()
This method gets the parent of this TreeNode.

Returns:
the parent TreeNode or null if this is the root- TreeNode.

getChildren

List<NODE> getChildren()
This method gets the List containing all children of this TreeNode. The List may be empty - in such case we call this TreeNode a leaf. Each item of the returned List is called a child or child-node. It should return this TreeNode as parent.

Returns:
the List containing all children of this TreeNode.

isDescendant

boolean isDescendant(TreeNode<?> node)
This method determines if this TreeNode is a descendant of the given node. In other words this method checks if this TreeNode is the direct or indirect child of the given node.

Parameters:
node - is the TreeNode to check (the potential ancestor).
Returns:
true if this TreeNode is an descendant of the given node.

isAncestor

boolean isAncestor(TreeNode<?> node)
This method determines if this TreeNode is an ancestor of the given node. In other words this method checks if this TreeNode is the direct or indirect parent of the given node.

Parameters:
node - is the TreeNode to check (the potential descendant).
Returns:
true if this TreeNode is an ancestor of the given node.


Copyright © 2001-2010 mmm-Team. All Rights Reserved.