Package org.revapi.base
Class BaseElementForest<E extends Element<E>>
- java.lang.Object
-
- org.revapi.base.BaseElementForest<E>
-
- Type Parameters:
E
- the base type of all the elements produced by some API analyzer
- All Implemented Interfaces:
ElementForest<E>
public class BaseElementForest<E extends Element<E>> extends Object implements ElementForest<E>
A convenience base class for element forest implementations.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.revapi.ElementForest
ElementForest.Visitor<E extends Element<E>>
-
-
Constructor Summary
Constructors Constructor Description BaseElementForest(API api)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description API
getApi()
SortedSet<E>
getRoots()
A sorted set of all root elements of the forest.protected SortedSet<E>
newRootsInstance()
protected <T extends Element<E>>
voidsearch(List<T> results, Class<T> resultType, SortedSet<E> siblings, boolean recurse, TreeFilter<E> filter)
<T extends Element<E>>
Stream<T>stream(Class<T> resultType, boolean recurse, TreeFilter<E> filter, Element<E> root)
Walks through the forest and returns a stream of elements that match the provided filter.String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.revapi.ElementForest
iterateOverElements, search, stream
-
-
-
-
Constructor Detail
-
BaseElementForest
public BaseElementForest(API api)
-
-
Method Detail
-
getApi
public API getApi()
- Specified by:
getApi
in interfaceElementForest<E extends Element<E>>
- Returns:
- the API this forest represents
-
getRoots
public SortedSet<E> getRoots()
Description copied from interface:ElementForest
A sorted set of all root elements of the forest. The set uses the natural order of the element implementations.- Specified by:
getRoots
in interfaceElementForest<E extends Element<E>>
- Returns:
- the roots elements of the forest.
-
stream
public <T extends Element<E>> Stream<T> stream(Class<T> resultType, boolean recurse, TreeFilter<E> filter, Element<E> root)
Description copied from interface:ElementForest
Walks through the forest and returns a stream of elements that match the provided filter.- Specified by:
stream
in interfaceElementForest<E extends Element<E>>
- Type Parameters:
T
- the expected type of results- Parameters:
resultType
- the expected type of resultsrecurse
- whether to recursively descend into children. If false, only the direct children of the root are searched.filter
- the filter to use when looking for matching childrenroot
- the search root. If null, the whole element forest is searched- Returns:
- the stream of the matching elements
-
search
protected <T extends Element<E>> void search(List<T> results, Class<T> resultType, SortedSet<E> siblings, boolean recurse, TreeFilter<E> filter)
-
-