E
- the parent type of all elements produced by the API analyzerpublic abstract class BaseArchiveAnalyzer<F extends BaseElementForest<E>,E extends BaseElement<E>> extends Object implements ArchiveAnalyzer<E>
analyze(TreeFilter)
) by requiring the subclasses to implement a more fine-grained "discovery" of
elements (preAnalyze()
, discoverRoots(Object)
, discoverElements(Object, BaseElement)
and
postAnalyze(Object)
).Constructor and Description |
---|
BaseArchiveAnalyzer(ApiAnalyzer<E> apiAnalyzer,
API api) |
Modifier and Type | Method and Description |
---|---|
protected void |
addTo(Object context,
TreeFilter<E> filter,
SortedSet<E> siblings,
E element)
Adds an element to the set of its potential siblings.
|
F |
analyze(TreeFilter<E> filter)
Analyzes the API archives and filters the forest using the provided filter.
|
protected abstract java.util.stream.Stream<E> |
discoverElements(Object context,
E parent)
Discovers new elements under the given parent element.
|
protected abstract java.util.stream.Stream<E> |
discoverRoots(Object context)
Discovers all the root elements in the relevant archives of the API.
|
API |
getApi() |
ApiAnalyzer<E> |
getApiAnalyzer() |
protected abstract F |
newElementForest()
Creates a new empty element forest of given type.
|
protected void |
postAnalyze(Object context)
Called as the last thing in
analyze(TreeFilter) . |
protected Object |
preAnalyze()
Called as the first thing in
analyze(TreeFilter) . |
void |
prune(ElementForest<E> forest)
Once all the filtering on the element forest is done, the analyzer is allowed one final "pass" through the forest
to remove any elements that should not be there any longer.
|
public BaseArchiveAnalyzer(ApiAnalyzer<E> apiAnalyzer, API api)
public ApiAnalyzer<E> getApiAnalyzer()
getApiAnalyzer
in interface ArchiveAnalyzer<E extends BaseElement<E>>
ApiAnalyzer
that created this instancepublic API getApi()
getApi
in interface ArchiveAnalyzer<E extends BaseElement<E>>
public F analyze(TreeFilter<E> filter)
ArchiveAnalyzer
This produces a preliminary forest which can be too "wide" because of FilterMatch.UNDECIDED
elements.
Once the preliminary forest is obtained and filtered down, it can then be pruned
by this analyzer to account for "non-local" effects removal of elements can have on it (like for example removal
of elements that are no longer used by any other element in the forest, if the analyzer deems it necessary).
analyze
in interface ArchiveAnalyzer<E extends BaseElement<E>>
filter
- the filter to use to "prune" the forestpublic void prune(ElementForest<E> forest)
ArchiveAnalyzer
prune
in interface ArchiveAnalyzer<E extends BaseElement<E>>
forest
- the forest to pruneprotected abstract F newElementForest()
@Nullable protected Object preAnalyze()
analyze(TreeFilter)
. Can be used by the subclasses to initialize themselves
for the analysis.postAnalyze(Object)
protected void postAnalyze(@Nullable Object context)
analyze(TreeFilter)
. Can be used by the subclasses to clean up after the
analysis.context
- the context object created in the preAnalyze()
preAnalyze()
protected abstract java.util.stream.Stream<E> discoverRoots(@Nullable Object context)
preAnalyze()
and before all discoverElements(Object, BaseElement)
calls.context
- the optional context obtained from the preAnalyze()
methodprotected abstract java.util.stream.Stream<E> discoverElements(@Nullable Object context, E parent)
parent
- the parent to discover children ofprotected final void addTo(@Nullable Object context, TreeFilter<E> filter, SortedSet<E> siblings, E element)
BaseElementForest
and therefore automatically update the parent-child relationships.
This method can be used to establish the right hierarchy of elements in the element forest.
filter
- the filter that the element needs to match to be added to the siblingssiblings
- the set of siblingselement
- the element to potentially add to siblingsCopyright © 2014-2021 Lukas Krejci. All Rights Reserved.