com.atlassian.greenhopper.service.hierarchy
Class Tree<T>

java.lang.Object
  extended by com.atlassian.greenhopper.service.hierarchy.Tree<T>

public class Tree<T>
extends java.lang.Object

A generic tree data structure. Nodes with a parent-child-relationship are used to link the tree data. Each node carries the actual data object as a payload. This way, the data can be kept unaware of the possibility of being tree-organised. TODO change to child-parent-link to evade recursion (see http://myarch.com/treeiter/traditways)

Author:
ahennecke

Constructor Summary
Tree(T data)
           
Tree(TreeNode<T> rootNode)
           
 
Method Summary
 java.util.List<TreeNode<T>> getAllNodes()
          Get a list of all tree nodes, starting with the root node.
 java.util.List<T> getDataFromAllChildren()
          Get a list of data payload objects from all children of the root node
 java.util.List<T> getDataFromAllChildren(java.util.Comparator<T> comp)
           
 java.util.List<T> getDataFromAllChildren(T parent)
          Get a list of data payload objects from all children of the given parent (possible sub-tree).
 java.util.List<T> getDataFromAllChildren(T parent, java.util.Comparator<T> comp)
          Get a list of data payload objects from all children of the given parent (possible sub-tree).
 TreeNode<T> getRootNode()
           
 boolean isChild(T potentialChild)
          Check if the given data payload is assigned to a child node
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Tree

public Tree(TreeNode<T> rootNode)

Tree

public Tree(T data)
Method Detail

getAllNodes

public java.util.List<TreeNode<T>> getAllNodes()
Get a list of all tree nodes, starting with the root node.


getDataFromAllChildren

public java.util.List<T> getDataFromAllChildren(T parent)
Get a list of data payload objects from all children of the given parent (possible sub-tree).


getDataFromAllChildren

public java.util.List<T> getDataFromAllChildren(T parent,
                                                java.util.Comparator<T> comp)
Get a list of data payload objects from all children of the given parent (possible sub-tree).


getDataFromAllChildren

public java.util.List<T> getDataFromAllChildren()
Get a list of data payload objects from all children of the root node


getDataFromAllChildren

public java.util.List<T> getDataFromAllChildren(java.util.Comparator<T> comp)

getRootNode

public TreeNode<T> getRootNode()

isChild

public boolean isChild(T potentialChild)
Check if the given data payload is assigned to a child node

Parameters:
potentialChild - : The data object to search for
Returns:
true if the data object is assigned to a child node of the root node


Copyright © 2007-2011 Atlassian. All Rights Reserved.