public interface Element extends Comparable<Element>
An element is comparable with all other element types for given language, giving a total ordering across all and any element types given language defines.
Modifier and Type | Method and Description |
---|---|
default <T extends Element> |
as(Class<T> type)
Casts this element to the provided type.
|
API |
getApi() |
Archive |
getArchive() |
SortedSet<? extends Element> |
getChildren() |
String |
getFullHumanReadableString()
Provides the full "path" to the element in the forest in a human readable way.
|
Element |
getParent() |
<T extends Element> |
iterateOverChildren(Class<T> resultType,
boolean recurse,
Filter<? super T> filter)
Similar to search methods but avoids the traversal over the whole forest.
|
<T extends Element> |
searchChildren(Class<T> resultType,
boolean recurse,
Filter<? super T> filter)
This method is functionally equivalent to
searchChildren(java.util.List, java.lang.Class, boolean,
org.revapi.query.Filter) but returns the result in a newly allocated list instance. |
<T extends Element> |
searchChildren(List<T> results,
Class<T> resultType,
boolean recurse,
Filter<? super T> filter)
Recursively searches the children of this element for elements of given type, potentially applicable to given
filter.
|
void |
setParent(Element parent)
Sets a new parent.
|
compareTo
default <T extends Element> T as(Class<T> type)
type
- the type to cast this instance toClassCastException
- if this instance cannot be cast to the provided type@Nullable Archive getArchive()
@Nullable Element getParent()
void setParent(@Nullable Element parent)
parent
- the new parent of this element@Nonnull String getFullHumanReadableString()
@Nonnull <T extends Element> List<T> searchChildren(@Nonnull Class<T> resultType, boolean recurse, @Nullable Filter<? super T> filter)
searchChildren(java.util.List, java.lang.Class, boolean,
org.revapi.query.Filter)
but returns the result in a newly allocated list instance. This is basically
a convenience method to enable a more succinct expressions.T
- the type of the elements to look forresultType
- the type of the elements to look forrecurse
- false to search only in direct children of the element, true to search recursivelyfilter
- optional filter to further trim the number of results @return the list of child elements of
given type potentially satisfying given filter<T extends Element> void searchChildren(@Nonnull List<T> results, @Nonnull Class<T> resultType, boolean recurse, @Nullable Filter<? super T> filter)
This is identical to searchChildren(Class, boolean, org.revapi.query.Filter)
in behavior but avoids
the instantiation of a new list.
T
- the type of the elements to look forresults
- the list of the results to fillresultType
- the type of the elements to look forrecurse
- false to search only in direct children of the element, true to search recursivelyfilter
- optional filter to further trim the number of results@Nonnull <T extends Element> Iterator<T> iterateOverChildren(@Nonnull Class<T> resultType, boolean recurse, @Nullable Filter<? super T> filter)
T
- the type of the elements to look forresultType
- the type of elements to look forrecurse
- if true, the iterator traverses the element forest using depth first searchfilter
- optional filter to further trim the number of resultssearchChildren(Class, boolean, org.revapi.query.Filter)
Copyright © 2014-2020 Lukas Krejci. All Rights Reserved.