org.omnaest.utils.structure.hierarchy.tree
Class TreeNavigator.TreeNodePathAndCache

java.lang.Object
  extended by org.omnaest.utils.structure.hierarchy.tree.TreeNavigator.TreeNodePathAndCache
Enclosing class:
TreeNavigator<T extends Tree<?,TN>,TN extends TreeNode>

protected class TreeNavigator.TreeNodePathAndCache
extends Object

Internal representation of the path of TreeNodes.

The children of all path TreeNodes are cached to allow sibling determination.

Author:
Omnaest

Field Summary
protected  Map<TN,List<TN>> treeNodeToChildrenListMap
           
 
Constructor Summary
protected TreeNavigator.TreeNodePathAndCache()
           
 
Method Summary
 void addTreeNodeToTreeNodePath(TN treeNode, Integer indexWithinParentChildrenList)
          Adds a new TreeNode to the current tree
 int determineIndexPositionOfCurrentTreeNodeWithinTheParentChildrenList()
           
 TreeNavigator.TreeNodePathAndCache fork()
          Creates a fork of the current TreeNavigator.TreeNodePathAndCache
 List<TN> getChildrenListFor(TN treeNode)
          Returns the List of children which are determined when the TreeNode is added to the TreeNavigator.TreeNodePathAndCache
 List<TN> getChildrenListOfCurrentTreeNode()
          Returns the children TreeNode List of the parental TreeNode
 List<TN> getChildrenListOfParent()
          Returns the children TreeNode List of the parental TreeNode
 TN getCurrentTreeNode()
          Returns the current TreeNode
 TN getParent()
          Returns the parent TreeNode of the current TreeNode is one exists, otherwise null
 List<TN> getTreeNodePathList()
           
 boolean isEmpty()
           
 void removeLastTreeNodeAndClearUnusedCachedChildrenLists()
          Removes the last current TreeNode
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

treeNodeToChildrenListMap

protected final Map<TN extends TreeNode,List<TN extends TreeNode>> treeNodeToChildrenListMap
Constructor Detail

TreeNavigator.TreeNodePathAndCache

protected TreeNavigator.TreeNodePathAndCache()
Method Detail

fork

public TreeNavigator.TreeNodePathAndCache fork()
Creates a fork of the current TreeNavigator.TreeNodePathAndCache

Returns:

addTreeNodeToTreeNodePath

public void addTreeNodeToTreeNodePath(TN treeNode,
                                      Integer indexWithinParentChildrenList)
Adds a new TreeNode to the current tree

Parameters:
treeNode -
indexWithinParentChildrenList -

size

public int size()
Returns:
See Also:
List.size()

isEmpty

public boolean isEmpty()
Returns:
See Also:
List.isEmpty()

getCurrentTreeNode

public TN getCurrentTreeNode()
Returns the current TreeNode

Returns:

removeLastTreeNodeAndClearUnusedCachedChildrenLists

public void removeLastTreeNodeAndClearUnusedCachedChildrenLists()
Removes the last current TreeNode


getChildrenListFor

public List<TN> getChildrenListFor(TN treeNode)
Returns the List of children which are determined when the TreeNode is added to the TreeNavigator.TreeNodePathAndCache

Parameters:
treeNode -
Returns:

getParent

public TN getParent()
Returns the parent TreeNode of the current TreeNode is one exists, otherwise null

Returns:

getChildrenListOfParent

public List<TN> getChildrenListOfParent()
Returns the children TreeNode List of the parental TreeNode

Returns:

getChildrenListOfCurrentTreeNode

public List<TN> getChildrenListOfCurrentTreeNode()
Returns the children TreeNode List of the parental TreeNode

Returns:

determineIndexPositionOfCurrentTreeNodeWithinTheParentChildrenList

public int determineIndexPositionOfCurrentTreeNodeWithinTheParentChildrenList()
Returns:
-1 if no parent is present

getTreeNodePathList

public List<TN> getTreeNodePathList()
Returns:
the treeNodePathList


Copyright © 2013. All Rights Reserved.