Class AbstractTreeNode<T>

java.lang.Object
org.ametys.cms.search.advanced.AbstractTreeNode<T>
Type Parameters:
T - the type of the values of the leaves of the tree.
Direct Known Subclasses:
TreeInternalNode, TreeLeaf

public abstract class AbstractTreeNode<T> extends Object
This abstract class represents a node in a tree data structure.
There are only two allowed sublcasses: TreeLeaf and TreeInternalNode
  • Constructor Details

  • Method Details

    • walk

      public static <T, R> R walk(AbstractTreeNode<T> tree, Function<TreeLeaf<T>,R> leafFunction, BiFunction<Stream<R>,Query.LogicalOperator,R> internalNodeFunction)
      Generic helper method to walk a tree (i.e. traverse a tree) for visiting each node and doing a recursive treatment
      This is a post-order walk (the children are traversed before their respective parents are traversed)
      See also this link
      Type Parameters:
      T - the type of the values of the leaves of the given tree
      R - the type of the object returned by this method.
      Parameters:
      tree - The tree to walk
      leafFunction - The operation to perform for a leaf
      internalNodeFunction - The operation to perform for an internal node.
      This function takes two arguments:
      • the results for each child as a stream;
      • the logical operator of the internal node
      Returns:
      a result
    • getFlatLeaves

      Gets all leaves of this tree node, recursively flattened.
      Returns:
      the flattened leaves