Class SuperInheritanceHierarchyFunction

java.lang.Object
spoon.reflect.visitor.filter.SuperInheritanceHierarchyFunction
All Implemented Interfaces:
CtConsumableFunction<CtTypeInformation>, CtQueryAware

public class SuperInheritanceHierarchyFunction extends Object implements CtConsumableFunction<CtTypeInformation>, CtQueryAware
Expects a CtTypeInformation as input and produces all super classes and super interfaces recursively.
The output is produced in following order:
  1. input type. if `includingSelf==true`
  2. all interfaces of type recursively
  3. parent class of type
  4. goto 1: using parent class as input type
  • Constructor Details

    • SuperInheritanceHierarchyFunction

      public SuperInheritanceHierarchyFunction()
      The mapping function created using this constructor will visit each super class and super interface following super hierarchy. It can happen that some interfaces will be visited more then once if they are in super inheritance hierarchy more then once.
      Use second constructor if you want to visit each interface only once.
    • SuperInheritanceHierarchyFunction

      public SuperInheritanceHierarchyFunction(Set<String> visitedSet)
      The mapping function created using this constructor will visit each super class and super interface following super hierarchy. It is assured that interfaces will be visited only once even if they are in super inheritance hierarchy more then once.
      Parameters:
      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.
  • Method Details

    • includingSelf

      public SuperInheritanceHierarchyFunction includingSelf(boolean includingSelf)
      Parameters:
      includingSelf - if true then input element is sent to output too. By default it is false.
    • includingInterfaces

      public SuperInheritanceHierarchyFunction includingInterfaces(boolean includingInterfaces)
      Parameters:
      includingInterfaces - if false then interfaces are not visited - only super classes. By default it is true.
    • returnTypeReferences

      public SuperInheritanceHierarchyFunction returnTypeReferences(boolean returnTypeReferences)
      configures whether CtType or CtTypeReference instances are returned by this mapping function
      Parameters:
      returnTypeReferences - if true then CtTypeReference instances are returned by this mapping function
      Returns:
      this to support fluent API
    • interfacesExtendObject

      public SuperInheritanceHierarchyFunction interfacesExtendObject(boolean interfacesExtendObject)
      configures whether it should visit 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 hierarchy
      Parameters:
      interfacesExtendObject - if true then Object is visited at the end too
      Returns:
      this to support fluent API
    • setListener

      public SuperInheritanceHierarchyFunction setListener(CtScannerListener listener)
      The listener evens are called in this order:
      1. enter(input element)
      2. return input element
      3. enter/exit for each super interface of input element recursively
      4. call 1-5) recursively where input element is super class of input element
      5. exit(input element)
      Note: this order is assured and some algorithms already depend on it!
      Parameters:
      listener - the implementation of CtScannerListener, which will listen for enter/exit of CtTypeReference during type hierarchy scanning
      Returns:
      this to support fluent API
    • failOnClassNotFound

      public SuperInheritanceHierarchyFunction failOnClassNotFound(boolean failOnClassNotFound)
      Parameters:
      failOnClassNotFound - sets whether processing should throw an exception if class is missing in noClassPath mode
    • apply

      public void apply(CtTypeInformation input, CtConsumer<Object> outputConsumer)
      Description copied from interface: CtConsumableFunction
      Evaluates the function on the given input.
      Specified by:
      apply in interface CtConsumableFunction<CtTypeInformation>
      Parameters:
      input - the input of the function
      outputConsumer - the consumer which accepts the results of this function.
    • visitSuperClasses

      protected void visitSuperClasses(CtTypeReference<?> superTypeRef, CtConsumer<Object> outputConsumer, boolean includingInterfaces)
      calls `outputConsumer.accept(superClass)` for all super classes of superType.
      Parameters:
      superTypeRef - the reference to a class. This method is called only for classes. Never for interface
      includingInterfaces - if true then all superInterfaces of each type are sent to `outputConsumer` too.
    • visitSuperInterfaces

      protected void visitSuperInterfaces(CtTypeReference<?> type, CtConsumer<Object> outputConsumer)
      calls `outputConsumer.accept(interface)` for all superInterfaces of type recursively.
    • setQuery

      public void setQuery(CtQuery query)
      Description copied from interface: CtQueryAware
      This method is called when the filter/function is added as a step to a CtQuery by the query engine (CtQueryImpl).
      Specified by:
      setQuery in interface CtQueryAware
      Parameters:
      query - an instance registering this function/filter.
    • sendResult

      protected void sendResult(CtTypeReference<?> typeRef, CtConsumer<Object> outputConsumer)