Class BaseElement<E extends Element<E>>
- java.lang.Object
- 
- org.revapi.base.BaseElement<E>
 
- 
- Type Parameters:
- E- the parent type of all elements in the API
 - All Implemented Interfaces:
- Cloneable,- Comparable<E>,- Element<E>
 
 public abstract class BaseElement<E extends Element<E>> extends Object implements Element<E>, Cloneable A base class for API elements. It is not mandatory to inherit from this class but it provides a good base implementation for most of the cases.The type parameter, <E>, denotes the parent type of all elements produced by a certainApiAnalyzer. All these types are assumed to be mutually comparable (and therefore implementComparable<E>).
- 
- 
Constructor SummaryConstructors Modifier Constructor Description protectedBaseElement(API api)protectedBaseElement(API api, Archive archive)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected EcastThis()Casts "this" toE.BaseElement<E>clone()Returns a shallow copy of this element.APIgetApi()ArchivegetArchive()SortedSet<E>getChildren()StringgetFullHumanReadableString()Provides the full "path" to the element in the forest in a human readable way.EgetParent()Set<Reference<E>>getReferencedElements()If the API analyzer supports the feature, this returns the set of elements that are referenced by this element in some way (typically, those would be the elements somehow used by this element).Set<Reference<E>>getReferencingElements()If the API analyzer supports the feature, this returns the set of elements that reference this element in some way (typically, those would be the use sites of this element).<T extends Element<E>>
 Iterator<T>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.protected Reference<E>newReference(E target, Reference.Type<E> type)Creates a new reference instance to be used in thegetReferencedElements()orgetReferencingElements().<T extends Element<E>>
 List<T>searchChildren(Class<T> resultType, boolean recurse, Filter<? super T> filter)This method is functionally equivalent toElement.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>>
 voidsearchChildren(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 voidsetArchive(Archive archive)voidsetParent(E parent)Sets the parent element.- 
Methods inherited from class java.lang.Objectequals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface java.lang.ComparablecompareTo
 - 
Methods inherited from interface org.revapi.Elementas, getCumulativeReferencedElements, getCumulativeReferencingElements, stream
 
- 
 
- 
- 
- 
Method Detail- 
castThisprotected E castThis() Casts "this" toE. This is unsafe from the language perspective but we supposeEis the base type of all elements of given API analyzer, so this should always be safe.- Returns:
- this instance as the base element type
 
 - 
getArchive@Nullable public Archive getArchive() - Specified by:
- getArchivein interface- Element<E extends Element<E>>
- Returns:
- the archive the element comes from or null if that cannot be determined
 
 - 
getFullHumanReadableString@Nonnull public String getFullHumanReadableString() Description copied from interface:ElementProvides the full "path" to the element in the forest in a human readable way. This method is meant to be used by the reporters to identify the element in the reports.- Specified by:
- getFullHumanReadableStringin interface- Element<E extends Element<E>>
- Returns:
- human readable representation of the element
 
 - 
setParentpublic void setParent(@Nullable E parent) Sets the parent element. No other processing is automagically done (i.e. the parent's children set is NOT updated by calling this method).
 - 
getChildren@Nonnull public SortedSet<E> getChildren() - Specified by:
- getChildrenin interface- Element<E extends Element<E>>
 
 - 
getReferencingElementspublic Set<Reference<E>> getReferencingElements() Description copied from interface:ElementIf the API analyzer supports the feature, this returns the set of elements that reference this element in some way (typically, those would be the use sites of this element).Note that, generally speaking, the references should not be used in TreeFilterimplementations because the filters are used during the construction of theElementForestmeaning that the references are not yet finalized at that point in time.- Specified by:
- getReferencingElementsin interface- Element<E extends Element<E>>
 
 - 
getReferencedElementspublic Set<Reference<E>> getReferencedElements() Description copied from interface:ElementIf the API analyzer supports the feature, this returns the set of elements that are referenced by this element in some way (typically, those would be the elements somehow used by this element).Note that, generally speaking, the references should not be used in TreeFilterimplementations because the filters are used during the construction of theElementForestmeaning that the references are not yet finalized at that point in time.- Specified by:
- getReferencedElementsin interface- Element<E extends Element<E>>
 
 - 
clonepublic BaseElement<E> clone() Returns a shallow copy of this element. In particular, its parent and children will be cleared.
 - 
newChildrenInstanceprotected 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. This default implementation merely returns an empty newTreeSetinstance.- Returns:
- a new sorted set instance to store the children in
 
 - 
searchChildrenpublic <T extends Element<E>> List<T> searchChildren(Class<T> resultType, boolean recurse, @Nullable Filter<? super T> filter) Description copied from interface:ElementThis method is functionally equivalent toElement.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.- Specified by:
- searchChildrenin interface- Element<E extends Element<E>>
- Type Parameters:
- T- the type of the elements to look for
- Parameters:
- resultType- the type of the elements to look for
- recurse- false to search only in direct children of the element, true to search recursively
- filter- optional filter to further trim the number of results @return the list of child elements of given type potentially satisfying given filter
- Returns:
- the list of found elements
 
 - 
searchChildrenpublic <T extends Element<E>> void searchChildren(List<T> results, Class<T> resultType, boolean recurse, @Nullable Filter<? super T> filter) Description copied from interface:ElementRecursively searches the children of this element for elements of given type, potentially applicable to given filter.This is identical to Element.searchChildren(Class, boolean, org.revapi.query.Filter)in behavior but avoids the instantiation of a new list.- Specified by:
- searchChildrenin interface- Element<E extends Element<E>>
- Type Parameters:
- T- the type of the elements to look for
- Parameters:
- results- the list of the results to fill
- resultType- the type of the elements to look for
- recurse- false to search only in direct children of the element, true to search recursively
- filter- optional filter to further trim the number of results
 
 - 
iterateOverChildrenpublic <T extends Element<E>> Iterator<T> iterateOverChildren(Class<T> resultType, boolean recurse, @Nullable Filter<? super T> filter) Description copied from interface:ElementSimilar to search methods but avoids the traversal over the whole forest. Instead the traversal is incremental and governed by the returned iterator.- Specified by:
- iterateOverChildrenin interface- Element<E extends Element<E>>
- Type Parameters:
- T- the type of the elements to look for
- Parameters:
- resultType- the type of elements to look for
- recurse- if true, the iterator traverses the element forest using depth first search
- filter- optional filter to further trim the number of results
- Returns:
- the iterator that will iterate over the results
- See Also:
- Element.searchChildren(Class, boolean, org.revapi.query.Filter)
 
 - 
newReferenceprotected Reference<E> newReference(E target, Reference.Type<E> type) Creates a new reference instance to be used in thegetReferencedElements()orgetReferencingElements(). This method should be overridden by any subclass that uses a subclass forReferencefor referencing the elements.- Parameters:
- target- the target element
- type- the type of the reference
- Returns:
- a new reference with given type pointing to the target element
 
 
- 
 
-