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
public abstract class AbstractTreeNode<T> extends Object
This abstract class represents a node in a tree data structure.
There are only two allowed sublcasses:TreeLeafandTreeInternalNode 
- 
- 
Constructor Summary
Constructors Constructor Description AbstractTreeNode() 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Collection<TreeLeaf<T>>getFlatLeaves()Gets all leaves of this tree node, recursively flattened.static <T,R>
Rwalk(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 Detail
- 
AbstractTreeNode
public AbstractTreeNode()
 
 - 
 
- 
Method Detail
- 
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
public Collection<TreeLeaf<T>> getFlatLeaves()
Gets all leaves of this tree node, recursively flattened.- Returns:
 - the flattened leaves
 
 
 - 
 
 -