Package org.revapi

Interface ElementForest<E extends Element<E>>

  • Type Parameters:
    E - the common super type of all elements in the forest
    All Known Implementing Classes:
    BaseElementForest, SimpleElementForest

    public interface ElementForest<E extends Element<E>>
    A representation of some "unit" understood by an API analyzer. Typically an abstract syntax tree of a language.
    Lukas Krejci
    • Method Detail

      • getApi

        API getApi()
        the API this forest represents
      • getRoots

        SortedSet<E> getRoots()
        A sorted set of all root elements of the forest. The set uses the natural order of the element implementations.
        the roots elements of the forest.
      • search

        default <T extends Element<T>> List<T> search​(@Nonnull
                                                      Class<T> resultType,
                                                      boolean recurse,
                                                      Filter<? super T> filter,
                                                      Element<T> searchRoot)
        in favor of more versatile stream(Class, boolean, Element)
        Searches through the forest for elements of given type, potentially further filtering.

        If the searchRoot is not null, this is technically equivalent to calling the Element.searchChildren(java.lang.Class, boolean, org.revapi.query.Filter) on the searchRoot.

        Type Parameters:
        T - the type of the elements to look for
        resultType - the type of the elements to be contained in the results
        recurse - false to only search direct children, true for searching recursively
        filter - the optional filter
        searchRoot - optional element from which to conduct the search
        a list of elements of given type (or any subtype) from the forest, filtered by the filter if provided
      • stream

        <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.
        Type Parameters:
        T - the expected type of results
        resultType - the expected type of results
        recurse - 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 children
        root - the search root. If null, the whole element forest is searched
        the stream of the matching elements