Package org.revapi.base
Class IncludeExcludeTreeFilter<E extends Element<E>>
- java.lang.Object
-
- org.revapi.base.BaseTreeFilter<E>
-
- org.revapi.base.IncludeExcludeTreeFilter<E>
-
- Type Parameters:
E-
- All Implemented Interfaces:
TreeFilter<E>
- Direct Known Subclasses:
OverridableIncludeExcludeTreeFilter
public class IncludeExcludeTreeFilter<E extends Element<E>> extends BaseTreeFilter<E>
A tree filter that uses a combination of an include and exclude filters to arrive at the filtering decisions. If there is no include filter defined, everything is included. If there is an exclude filter defined, it excludes from the included elements.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classIncludeExcludeTreeFilter.IncludeExcludeResult
-
Constructor Summary
Constructors Constructor Description IncludeExcludeTreeFilter(TreeFilter<E> include, TreeFilter<E> exclude)A lack of any include or exclude filter needs to be expressed as a null value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected IncludeExcludeTreeFilter.IncludeExcludeResultconstructResult(FilterStartResult inclusion, FilterStartResult exclusion, IncludeExcludeTreeFilter.IncludeExcludeResult parent)protected IncludeExcludeTreeFilter.IncludeExcludeResultdoStart(E element)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).FilterFinishResultfinish(E element)This method is called after the filtering hasstartedand all children have been processed by this filter.protected FilterStartResultprocessExcludeStart(FilterStartResult result)protected FilterStartResultprocessIncludeStart(FilterStartResult result)FilterStartResultstart(E element)This method is called when an element is about to be filtered.
-
-
-
Constructor Detail
-
IncludeExcludeTreeFilter
public IncludeExcludeTreeFilter(@Nullable TreeFilter<E> include, @Nullable TreeFilter<E> exclude)
A lack of any include or exclude filter needs to be expressed as a null value.- Parameters:
include- the include filter or null if there is no include filterexclude- the exclude filter or null if there is no exclude filter
-
-
Method Detail
-
start
public FilterStartResult start(E element)
Description copied from interface:TreeFilterThis 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, theTreeFilter.finish(Element)will be called with the same element as this method.- Specified by:
startin interfaceTreeFilter<E extends Element<E>>- Overrides:
startin classBaseTreeFilter<E extends Element<E>>- 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
-
doStart
protected IncludeExcludeTreeFilter.IncludeExcludeResult doStart(E element)
-
constructResult
protected IncludeExcludeTreeFilter.IncludeExcludeResult constructResult(@Nullable FilterStartResult inclusion, @Nullable FilterStartResult exclusion, @Nullable IncludeExcludeTreeFilter.IncludeExcludeResult parent)
-
processIncludeStart
@Nullable protected FilterStartResult processIncludeStart(@Nullable FilterStartResult result)
-
processExcludeStart
@Nullable protected FilterStartResult processExcludeStart(@Nullable FilterStartResult result)
-
finish
public FilterFinishResult finish(E element)
Description copied from interface:TreeFilterThis method is called after the filtering hasstartedand 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 theTreeFilter.finish()method.- Specified by:
finishin interfaceTreeFilter<E extends Element<E>>- Overrides:
finishin classBaseTreeFilter<E extends Element<E>>- Parameters:
element- the element for which the filtering has finished- Returns:
- the result of filtering
-
finish
public Map<E,FilterFinishResult> finish()
Description copied from interface:TreeFilterCalled 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.- Specified by:
finishin interfaceTreeFilter<E extends Element<E>>- Overrides:
finishin classBaseTreeFilter<E extends Element<E>>- Returns:
- the final results for elements that were previously undecided if their filtering status changed
-
-