public class SuperInheritanceHierarchyFunction extends java.lang.Object implements CtConsumableFunction<CtTypeInformation>, CtQueryAware
CtTypeInformation
as input
and produces all super classes and super interfaces recursively.Modifier and Type | Class and Description |
---|---|
static class |
SuperInheritanceHierarchyFunction.DistinctTypeListener
Implementation of
CtScannerListener ,
which is used to assure that each interface is visited only once. |
Constructor and Description |
---|
SuperInheritanceHierarchyFunction()
The mapping function created using this constructor
will visit each super class and super interface
following super hierarchy.
|
SuperInheritanceHierarchyFunction(java.util.Set<java.lang.String> visitedSet)
The mapping function created using this constructor
will visit each super class and super interface
following super hierarchy.
|
Modifier and Type | Method and Description |
---|---|
void |
apply(CtTypeInformation input,
CtConsumer<java.lang.Object> outputConsumer)
Evaluates the function on the given input.
|
SuperInheritanceHierarchyFunction |
failOnClassNotFound(boolean failOnClassNotFound) |
SuperInheritanceHierarchyFunction |
includingInterfaces(boolean includingInterfaces) |
SuperInheritanceHierarchyFunction |
includingSelf(boolean includingSelf) |
SuperInheritanceHierarchyFunction |
interfacesExtendObject(boolean interfacesExtendObject)
configures whether it should visit
Object at the end of interface extends interface hierarchy. |
SuperInheritanceHierarchyFunction |
returnTypeReferences(boolean returnTypeReferences)
configures whether
CtType or CtTypeReference instances are returned by this mapping function |
protected void |
sendResult(CtTypeReference<?> typeRef,
CtConsumer<java.lang.Object> outputConsumer) |
SuperInheritanceHierarchyFunction |
setListener(CtScannerListener listener)
The listener evens are called in this order:
enter(input element)
return input element
enter/exit for each super interface of input element recursively
call 1-5) recursively where input element is super class of input element
exit(input element)
Note: this order is assured and some algorithms already depend on it!
|
void |
setQuery(CtQuery query)
This method is called when the filter/function is added as a step to a
CtQuery by the query engine (CtQueryImpl ). |
protected void |
visitSuperClasses(CtTypeReference<?> superTypeRef,
CtConsumer<java.lang.Object> outputConsumer,
boolean includingInterfaces)
calls `outputConsumer.accept(superClass)` for all super classes of superType.
|
protected void |
visitSuperInterfaces(CtTypeReference<?> type,
CtConsumer<java.lang.Object> outputConsumer)
calls `outputConsumer.accept(interface)` for all superInterfaces of type recursively.
|
public SuperInheritanceHierarchyFunction()
public SuperInheritanceHierarchyFunction(java.util.Set<java.lang.String> visitedSet)
visitedSet
- assures that each class/interface is visited only once
The types which are already contained in `visitedSet` are not visited
and not returned by this mapping function.public SuperInheritanceHierarchyFunction includingSelf(boolean includingSelf)
includingSelf
- if true then input element is sent to output too. By default it is false.public SuperInheritanceHierarchyFunction includingInterfaces(boolean includingInterfaces)
includingInterfaces
- if false then interfaces are not visited - only super classes. By default it is true.public SuperInheritanceHierarchyFunction returnTypeReferences(boolean returnTypeReferences)
CtType
or CtTypeReference
instances are returned by this mapping functionreturnTypeReferences
- if true then CtTypeReference
instances are returned by this mapping functionpublic SuperInheritanceHierarchyFunction interfacesExtendObject(boolean interfacesExtendObject)
Object
at the end of interface extends interface hierarchy.
Note: interface cannot extend Object (only other interfaces),
but note that interface inherits all public type members of Object
,
so there are use cases where client wants to visit Object as last member of interface inheritance hierarchyinterfacesExtendObject
- if true then Object
is visited at the end toopublic SuperInheritanceHierarchyFunction setListener(CtScannerListener listener)
listener
- the implementation of CtScannerListener
, which will listen for enter/exit of CtTypeReference
during type hierarchy scanningpublic SuperInheritanceHierarchyFunction failOnClassNotFound(boolean failOnClassNotFound)
failOnClassNotFound
- sets whether processing should throw an exception if class is missing in noClassPath modepublic void apply(CtTypeInformation input, CtConsumer<java.lang.Object> outputConsumer)
CtConsumableFunction
apply
in interface CtConsumableFunction<CtTypeInformation>
input
- the input of the functionoutputConsumer
- the consumer which accepts the results of this function.protected void visitSuperClasses(CtTypeReference<?> superTypeRef, CtConsumer<java.lang.Object> outputConsumer, boolean includingInterfaces)
superTypeRef
- the reference to a class. This method is called only for classes. Never for interfaceincludingInterfaces
- if true then all superInterfaces of each type are sent to `outputConsumer` too.protected void visitSuperInterfaces(CtTypeReference<?> type, CtConsumer<java.lang.Object> outputConsumer)
public void setQuery(CtQuery query)
CtQueryAware
CtQuery
by the query engine (CtQueryImpl
).setQuery
in interface CtQueryAware
query
- an instance registering this function/filter.protected void sendResult(CtTypeReference<?> typeRef, CtConsumer<java.lang.Object> outputConsumer)
Copyright © 2007–2021 Inria. All rights reserved.