Package org.revapi
Interface TreeFilter<E extends Element<E>>
-
- All Known Implementing Classes:
BaseTreeFilter
,IncludeExcludeTreeFilter
,IndependentTreeFilter
,OverridableIncludeExcludeTreeFilter
public interface TreeFilter<E extends Element<E>>
A tree filter is something that is called repeatedly by the caller as the caller walks a tree of elements in a depth first search manner. The tree filter gives the caller filtering results and walk instructions.As a caller of some implementation of this interface, please study the documentation of the individual methods on this interface to learn at what times the methods are supposed to be called.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description Map<E,FilterFinishResult>
finish()
Called after all elements have been processed to see if any of them have changed in their filtering result (which could be the case if there are dependencies between elements other than that of parent-child).FilterFinishResult
finish(E element)
This method is called after the filtering hasstarted
and all children have been processed by this filter.static <E extends Element<E>>
TreeFilter<E>intersection(List<TreeFilter<E>> fs)
Returns a filter that matches if all of the provided filters match.static <E extends Element<E>>
TreeFilter<E>intersection(TreeFilter<E>... fs)
static <E extends Element<E>>
TreeFilter<E>matchAndDescend()
static <E extends Element<E>>
TreeFilter<E>merge(BinaryOperator<FilterStartResult> mergeStarts, BinaryOperator<FilterFinishResult> mergeFinishes, FilterStartResult defaultStartResult, FilterFinishResult defaultFinishResult, List<TreeFilter<E>> fs)
Merges the filters together using the provided functions to combine the individual results.static <E extends Element<E>>
TreeFilter<E>merge(BinaryOperator<FilterStartResult> mergeStarts, BinaryOperator<FilterFinishResult> mergeFinishes, FilterStartResult defaultStartResult, FilterFinishResult defaultFinishResult, TreeFilter<E>... fs)
FilterStartResult
start(E element)
This method is called when an element is about to be filtered.static <E extends Element<E>>
TreeFilter<E>union(List<TreeFilter<E>> fs)
static <E extends Element<E>>
TreeFilter<E>union(TreeFilter<E>... fs)
-
-
-
Method Detail
-
matchAndDescend
static <E extends Element<E>> TreeFilter<E> matchAndDescend()
-
merge
@SafeVarargs static <E extends Element<E>> TreeFilter<E> merge(BinaryOperator<FilterStartResult> mergeStarts, BinaryOperator<FilterFinishResult> mergeFinishes, FilterStartResult defaultStartResult, FilterFinishResult defaultFinishResult, TreeFilter<E>... fs)
-
merge
static <E extends Element<E>> TreeFilter<E> merge(BinaryOperator<FilterStartResult> mergeStarts, BinaryOperator<FilterFinishResult> mergeFinishes, FilterStartResult defaultStartResult, FilterFinishResult defaultFinishResult, List<TreeFilter<E>> fs)
Merges the filters together using the provided functions to combine the individual results.- Parameters:
mergeStarts
- the function to combine two filter start resultsmergeFinishes
- the function to combine two filter finish resultsdefaultStartResult
- the default start result in case there are no filters in the provided listdefaultFinishResult
- the default finish result in case there are no filters in the provided listfs
- the list of filters to merge
-
intersection
@SafeVarargs static <E extends Element<E>> TreeFilter<E> intersection(TreeFilter<E>... fs)
- See Also:
intersection(List)
-
intersection
static <E extends Element<E>> TreeFilter<E> intersection(List<TreeFilter<E>> fs)
Returns a filter that matches if all of the provided filters match.
-
union
@SafeVarargs static <E extends Element<E>> TreeFilter<E> union(TreeFilter<E>... fs)
- See Also:
union(List)
-
union
static <E extends Element<E>> TreeFilter<E> union(List<TreeFilter<E>> fs)
- Returns:
- a filter that matches if at least one of the provided filters matches.
-
start
FilterStartResult start(E element)
This method is called when an element is about to be filtered. After this call all the children will be processed (if the result instructs the caller to do so). Only after that, thefinish(Element)
will be called with the same element as this method.- Parameters:
element
- the element to start filtering- Returns:
- a filter result informing the caller what was the result of filtering and whether to descend to children or not
-
finish
FilterFinishResult finish(E element)
This method is called after the filtering hasstarted
and all children have been processed by this filter.Note that the result can still be
Ternary.UNDECIDED
. It is expected that such elements will in the end be resolved with thefinish()
method.- Parameters:
element
- the element for which the filtering has finished- Returns:
- the result of filtering
-
finish
Map<E,FilterFinishResult> finish()
Called after all elements have been processed to see if any of them have changed in their filtering result (which could be the case if there are dependencies between elements other than that of parent-child).Note that the result can remain
Ternary.UNDECIDED
. It is upon the caller to then decide what to do with such elements.- Returns:
- the final results for elements that were previously undecided if their filtering status changed
-
-