- java.lang.Object
-
- io.github.astrapi69.gen.tree.convert.BaseTreeNodeTransformer
-
public final class BaseTreeNodeTransformer extends java.lang.Object
The classBaseTreeNodeTransformer
provides algorithms for converting between theBaseTreeNode
objects andTreeIdNode
objects. This is useful if you want to saveBaseTreeNode
objects in a store, you have first to transform theBaseTreeNode
objects (you want to store) toTreeIdNode
objects and save them. TheBaseTreeNode
object is not be stored.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T,K>
BaseTreeNode<T,K>getRoot(@NonNull java.util.Map<K,TreeIdNode<T,K>> treeIdNodeMap)
Retrieves the rootBaseTreeNode
object from the given @link Map} object that containsTreeIdNode
objects as values and the id as keystatic <T,K>
java.util.Map<K,BaseTreeNode<T,K>>toKeyBaseTreeNodeMap(@NonNull BaseTreeNode<T,K> root)
Transforms the givenBaseTreeNode
object to aMap
object with the key and the correspondingBaseTreeNode
objectsstatic <T,K>
java.util.Map<K,TreeIdNode<T,K>>toKeyMap(@NonNull BaseTreeNode<T,K> root)
Transforms the givenBaseTreeNode
object to aMap
object with the key and the correspondingTreeIdNode
objectsstatic <T,K>
TreeIdNode<T,K>toTreeIdNode(@NonNull BaseTreeNode<T,K> baseTreeNode)
Transforms the givenBaseTreeNode
object to aTreeIdNode
objectstatic <T,K>
java.util.Map<K,BaseTreeNode<T,K>>transform(@NonNull java.util.Map<K,TreeIdNode<T,K>> treeIdNodeMap)
Transforms the givenMap
object that containsTreeIdNode
objects as values and the id as key
-
-
-
Method Detail
-
toKeyMap
public static <T,K> java.util.Map<K,TreeIdNode<T,K>> toKeyMap(@NonNull @NonNull BaseTreeNode<T,K> root)
Transforms the givenBaseTreeNode
object to aMap
object with the key and the correspondingTreeIdNode
objects- Type Parameters:
T
- the generic type of the valueK
- the generic type of the id of the node- Parameters:
root
- theBaseTreeNode
object to transform- Returns:
- a
Map
object with the correspondingTreeIdNode
objects
-
toTreeIdNode
public static <T,K> TreeIdNode<T,K> toTreeIdNode(@NonNull @NonNull BaseTreeNode<T,K> baseTreeNode)
Transforms the givenBaseTreeNode
object to aTreeIdNode
object- Type Parameters:
T
- the generic type of the valueK
- the generic type of the id of the node- Parameters:
baseTreeNode
- theBaseTreeNode
object to convert- Returns:
- the new created
TreeIdNode
object
-
toKeyBaseTreeNodeMap
public static <T,K> java.util.Map<K,BaseTreeNode<T,K>> toKeyBaseTreeNodeMap(@NonNull @NonNull BaseTreeNode<T,K> root)
Transforms the givenBaseTreeNode
object to aMap
object with the key and the correspondingBaseTreeNode
objects- Type Parameters:
T
- the generic type of the valueK
- the generic type of the id of the node- Parameters:
root
- theBaseTreeNode
object to transform- Returns:
- a
Map
object with the correspondingBaseTreeNode
objects
-
transform
public static <T,K> java.util.Map<K,BaseTreeNode<T,K>> transform(@NonNull @NonNull java.util.Map<K,TreeIdNode<T,K>> treeIdNodeMap)
Transforms the givenMap
object that containsTreeIdNode
objects as values and the id as key- Type Parameters:
T
- the generic type of the valueK
- the generic type of the id of the node- Parameters:
treeIdNodeMap
- theMap
object with theTreeIdNode
objects to transform- Returns:
- a
Map
object with the correspondingBaseTreeNode
objects
-
getRoot
public static <T,K> BaseTreeNode<T,K> getRoot(@NonNull @NonNull java.util.Map<K,TreeIdNode<T,K>> treeIdNodeMap)
Retrieves the rootBaseTreeNode
object from the given @link Map} object that containsTreeIdNode
objects as values and the id as key- Type Parameters:
T
- the generic type of the valueK
- the generic type of the id of the node- Parameters:
treeIdNodeMap
- theMap
object with theTreeIdNode
objects to transform- Returns:
- the root
BaseTreeNode
object or null if not found
-
-