E
- the parent type of all elements in the APIpublic abstract class BaseElement<E extends Element<E>> extends Object implements Element<E>, Cloneable
The type parameter, <E>
, denotes the parent type of all elements produced by a certain
ApiAnalyzer
. All these types are assumed to be mutually comparable (and therefore implement
Comparable<E>
).
Modifier | Constructor and Description |
---|---|
protected |
BaseElement(API api) |
protected |
BaseElement(API api,
Archive archive) |
Modifier and Type | Method and Description |
---|---|
protected E |
castThis()
Casts "this" to
E . |
BaseElement<E> |
clone()
Returns a shallow copy of this element.
|
API |
getApi() |
Archive |
getArchive() |
SortedSet<E> |
getChildren() |
String |
getFullHumanReadableString()
Provides the full "path" to the element in the forest in a human readable way.
|
E |
getParent() |
<T extends Element<E>> |
iterateOverChildren(Class<T> resultType,
boolean recurse,
Filter<? super T> filter)
Similar to search methods but avoids the traversal over the whole forest.
|
protected SortedSet<E> |
newChildrenInstance()
Override this method if you need some specialized instance of sorted set or want to do some custom pre-populating
or initialization of the children.
|
<T extends Element<E>> |
searchChildren(Class<T> resultType,
boolean recurse,
Filter<? super T> filter)
This method is functionally equivalent to
Element.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<E>> |
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.
|
protected void |
setArchive(Archive archive) |
void |
setParent(E parent)
Sets the parent element.
|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
compareTo
protected BaseElement(API api)
api
- protected E castThis()
E
. This is unsafe from the language perspective but we suppose E
is the base
type of all elements of given API analyzer, so this should always be safe.@Nullable public Archive getArchive()
getArchive
in interface Element<E extends Element<E>>
@Nonnull public String getFullHumanReadableString()
Element
getFullHumanReadableString
in interface Element<E extends Element<E>>
public void setParent(@Nullable E parent)
@Nonnull public SortedSet<E> getChildren()
getChildren
in interface Element<E extends Element<E>>
public BaseElement<E> clone()
@Nonnull protected SortedSet<E> newChildrenInstance()
TreeSet
instance.@Nonnull public <T extends Element<E>> List<T> searchChildren(@Nonnull Class<T> resultType, boolean recurse, @Nullable Filter<? super T> filter)
Element
Element.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.searchChildren
in interface Element<E extends Element<E>>
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 filterpublic <T extends Element<E>> void searchChildren(@Nonnull List<T> results, @Nonnull Class<T> resultType, boolean recurse, @Nullable Filter<? super T> filter)
Element
This is identical to Element.searchChildren(Class, boolean, org.revapi.query.Filter)
in behavior but avoids
the instantiation of a new list.
searchChildren
in interface Element<E extends Element<E>>
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 public <T extends Element<E>> Iterator<T> iterateOverChildren(@Nonnull Class<T> resultType, boolean recurse, @Nullable Filter<? super T> filter)
Element
iterateOverChildren
in interface Element<E extends Element<E>>
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 resultsElement.searchChildren(Class, boolean, org.revapi.query.Filter)
Copyright © 2014-2021 Lukas Krejci. All Rights Reserved.