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.
    Since:
    0.1
    Author:
    Lukas Krejci
    • Method Detail

      • getApi

        API getApi()
        Returns:
        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.
        Returns:
        the roots elements of the forest.
      • search

        @Deprecated
        @Nonnull
        default <T extends Element<T>> List<T> search​(@Nonnull
                                                      Class<T> resultType,
                                                      boolean recurse,
                                                      @Nullable
                                                      Filter<? super T> filter,
                                                      @Nullable
                                                      Element<T> searchRoot)
        Deprecated.
        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
        Parameters:
        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
        Returns:
        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,
                                                @Nullable
                                                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
        Parameters:
        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
        Returns:
        the stream of the matching elements