org.squashtest.csp.tm.domain.library.structures
Class TreeNode<T extends TreeNode<T>>

java.lang.Object
  extended by org.squashtest.csp.tm.domain.library.structures.TreeNode<T>
Type Parameters:
T - the type of the actual subclass.

public abstract class TreeNode<T extends TreeNode<T>>
extends Object

Please read also LibraryTree.

TreeNode is the type of node used by a LibraryTree. A TreeNode maintains informations regarding its position in the tree, ie its parent node, its layer/depth etc. Each node is identified by a key, that will be used to identify each node uniquely. While that class does not override equals/hashCode using the key as the sole criteria, it proposes instead a method (isSame(TreeNode) for that.

Subclasses of TreeNode should be genericized Enum-style, i.e. generics of themselves, and implement updateWith(TreeNode).

Author:
bsiri

Constructor Summary
TreeNode()
           
TreeNode(Long key)
           
 
Method Summary
 List<T> getChildren()
           
 Long getKey()
           
 boolean isSame(T node)
           That method tells if two nodes refer to the same node.
 void setKey(Long key)
           
protected abstract  void updateWith(T newData)
          strongly recommended to override/specialize that method when you subtype that class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeNode

public TreeNode()

TreeNode

public TreeNode(Long key)
Method Detail

getChildren

public List<T> getChildren()
Returns:
the children nodes of this node.

getKey

public Long getKey()

setKey

public void setKey(Long key)

isSame

public boolean isSame(T node)

That method tells if two nodes refer to the same node. Two nodes are considered as same if their keys are equal regardless of their other properties. A node compared to null is considered different. Two node having null keys are considered as same, thought that feature is not used in theory.

Parameters:
node -
Returns:

updateWith

protected abstract void updateWith(T newData)
strongly recommended to override/specialize that method when you subtype that class.

Parameters:
newData -


Copyright © 2010-2012 Squashtest TM, Squashtest.org. All Rights Reserved.