Class GenericTree<T>
- java.lang.Object
-
- de.captaingoldfish.scim.sdk.common.tree.GenericTree<T>
-
public class GenericTree<T> extends Object
this implementation represents a tree with several root-nodes and each node might have several parents and several children. This tree implementation is not thread-safe!- Since:
- 25.03.2022
- Author:
- Pascal Knueppel
-
-
Constructor Summary
Constructors Constructor Description GenericTree()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TreeNode<T>addDistinctNode(T value)creates a new node if a node with the same value does not exist yet and returns the existing node if a node with an identical value does already existprotected voidaddLeaf(TreeNode<T> treeNode)method is only called by tree nodesTreeNode<T>addNewNode(T value)creates a new tree node with this tree as its parentprotected voidaddNode(TreeNode<T> treeNode)protected voidaddRoot(TreeNode<T> treeNode)Set<TreeNode<T>>getAllNodes()Set<TreeNode<T>>getLeafs()Set<TreeNode<T>>getRoots()booleanhasNodes()if this tree still has any nodes leftvoidremoveBranchFromTree(TreeNode<T> treeNode)removes the branch from the tree represented by the given treenodeprotected voidremoveLeaf(TreeNode<T> treeNode)voidremoveNodeFromTree(TreeNode<T> treeNode)removes a single node from the tree.protected voidremoveRoot(TreeNode<T> treeNode)
-
-
-
Method Detail
-
addNewNode
public TreeNode<T> addNewNode(T value)
creates a new tree node with this tree as its parent- Parameters:
parents- the parents of the new node. May be nullvalue- the actual value of the nodechildren- the children of the node. May be null- Returns:
- a new tree-node that is a child of this tree
-
removeNodeFromTree
public void removeNodeFromTree(TreeNode<T> treeNode)
removes a single node from the tree. If the node was somewhere in the middle of the tree we will basically get a second tree because its branch was cut off from the first tree
-
removeBranchFromTree
public void removeBranchFromTree(TreeNode<T> treeNode)
removes the branch from the tree represented by the given treenode- Parameters:
treeNode- the branch to remove
-
addDistinctNode
public TreeNode<T> addDistinctNode(T value)
creates a new node if a node with the same value does not exist yet and returns the existing node if a node with an identical value does already exist
-
hasNodes
public boolean hasNodes()
if this tree still has any nodes left
-
-