Class SubInheritanceHierarchyResolver


public class SubInheritanceHierarchyResolver extends Object
Expects a CtPackage as input and upon calls to forEachSubTypeInPackage produces all sub classes and sub interfaces, which extends or implements super type(s) provided by call(s) of addSuperType(CtTypeInformation) and stored as `targetSuperTypes`.
The repeated processing of this mapping function on the same input returns only newly found sub types. The instance of SubInheritanceHierarchyResolver returns found sub types only once. So repeated call with same input package returns nothing. Create and use new instance of SubInheritanceHierarchyResolver if you need to scan the subtype hierarchy again.
  • Constructor Details

    • SubInheritanceHierarchyResolver

      public SubInheritanceHierarchyResolver(CtPackage input)
  • Method Details

    • addSuperType

      public SubInheritanceHierarchyResolver addSuperType(CtTypeInformation superType)
      Add another super type to this mapping function. Using this function you can search parallel in more sub type hierarchies.
      superType - - the type whose sub types will be returned by this mapping function too.
    • includingInterfaces

      public SubInheritanceHierarchyResolver includingInterfaces(boolean includingInterfaces)
      includingInterfaces - if false then interfaces are not visited - only super classes. By default it is true.
    • failOnClassNotFound

      public SubInheritanceHierarchyResolver failOnClassNotFound(boolean failOnClassNotFound)
      failOnClassNotFound - sets whether processing should throw an exception if class is missing in noClassPath mode
    • forEachSubTypeInPackage

      public <T extends CtType<?>> void forEachSubTypeInPackage(CtConsumer<T> outputConsumer)
      Calls `outputConsumer.apply(subType)` for each sub type of the targetSuperTypes that are found in `inputPackage`. Each sub type is returned only once. It makes sense to call this method again for example after new super types are added by addSuperType(CtTypeInformation). If this method is called again with same input and configuration, nothing in sent to outputConsumer
      outputConsumer - the consumer for found sub types