Class BaseTreeNodeTransformer

java.lang.Object
io.github.astrapi69.gen.tree.convert.BaseTreeNodeTransformer

public final class BaseTreeNodeTransformer extends Object
The class BaseTreeNodeTransformer provides algorithms for converting between the BaseTreeNode objects and TreeIdNode objects. This is useful if you want to save BaseTreeNode objects in a store, you have first to transform the BaseTreeNode objects (you want to store) to TreeIdNode objects and save them. Note: The BaseTreeNode object can not be stored
  • Method Details

    • toKeyMap

      public static <T, K> Map<K,TreeIdNode<T,K>> toKeyMap(@NonNull @NonNull BaseTreeNode<T,K> root)
      Transforms the given BaseTreeNode object to a Map object with the key and the corresponding TreeIdNode objects
      Type Parameters:
      T - the generic type of the value
      K - the generic type of the id of the node
      Parameters:
      root - the BaseTreeNode object to transform
      Returns:
      a Map object with the corresponding TreeIdNode objects
    • toTreeIdNode

      public static <T, K> TreeIdNode<T,K> toTreeIdNode(@NonNull @NonNull BaseTreeNode<T,K> baseTreeNode)
      Transforms the given BaseTreeNode object to a TreeIdNode object
      Type Parameters:
      T - the generic type of the value
      K - the generic type of the id of the node
      Parameters:
      baseTreeNode - the BaseTreeNode object to convert
      Returns:
      the new created TreeIdNode object
    • toKeyBaseTreeNodeMap

      public static <T, K> Map<K,BaseTreeNode<T,K>> toKeyBaseTreeNodeMap(@NonNull @NonNull BaseTreeNode<T,K> root)
      Transforms the given BaseTreeNode object to a Map object with the key and the corresponding BaseTreeNode objects
      Type Parameters:
      T - the generic type of the value
      K - the generic type of the id of the node
      Parameters:
      root - the BaseTreeNode object to transform
      Returns:
      a Map object with the corresponding BaseTreeNode objects
    • transform

      public static <T, K> Map<K,BaseTreeNode<T,K>> transform(@NonNull @NonNull Map<K,TreeIdNode<T,K>> treeIdNodeMap)
      Transforms the given Map object that contains TreeIdNode objects as values and the id as key
      Type Parameters:
      T - the generic type of the value
      K - the generic type of the id of the node
      Parameters:
      treeIdNodeMap - the Map object with the TreeIdNode objects to transform
      Returns:
      a Map object with the corresponding BaseTreeNode objects
    • getRoot

      public static <T, K> BaseTreeNode<T,K> getRoot(@NonNull @NonNull Map<K,TreeIdNode<T,K>> treeIdNodeMap)
      Retrieves the root BaseTreeNode object from the given @link Map} object that contains TreeIdNode objects as values and the id as key
      Type Parameters:
      T - the generic type of the value
      K - the generic type of the id of the node
      Parameters:
      treeIdNodeMap - the Map object with the TreeIdNode objects to transform
      Returns:
      the root BaseTreeNode object or null if not found