Package org.ametys.cms.search.advanced
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
This abstract class represents a node in a tree data structure.
There are only two allowed sublcasses:
There are only two allowed sublcasses:
TreeLeaf
and TreeInternalNode
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGets all leaves of this tree node, recursively flattened.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.
-
Constructor Details
-
AbstractTreeNode
public AbstractTreeNode()
-
-
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 treeR
- the type of the object returned by this method.- Parameters:
tree
- The tree to walkleafFunction
- The operation to perform for a leafinternalNodeFunction
- 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
-