Interface IndexView

All Known Implementing Classes:
CompositeIndex, Index

public interface IndexView
The basic contract for accessing Jandex indexed information.
  • Method Details

    • getKnownClasses

      Collection<ClassInfo> getKnownClasses()
      Gets all known classes by this index (those which were scanned).
      Returns:
      a collection of known classes
    • getClassByName

      ClassInfo getClassByName(DotName className)
      Gets the class (or interface, or annotation) that was scanned during the indexing phase.
      Parameters:
      className - the name of the class
      Returns:
      information about the class or null if it is not known
    • getKnownDirectSubclasses

      Collection<ClassInfo> getKnownDirectSubclasses(DotName className)
      Gets all known direct subclasses of the specified class name. A known direct subclass is one which was found during the scanning process; however, this is often not the complete universe of subclasses, since typically indexes are constructed per jar. It is expected that several indexes will need to be searched when analyzing a jar that is a part of a complex multi-module/classloader environment (like an EE application server).

      Note that this will only pick up direct subclasses of the class. It will not pick up subclasses of subclasses.

      Parameters:
      className - the super class of the desired subclasses
      Returns:
      a non-null list of all known subclasses of className
    • getAllKnownSubclasses

      Collection<ClassInfo> getAllKnownSubclasses(DotName className)
      Returns all known (including non-direct) sub classes of the given class. I.e., returns all known classes that are assignable to the given class.
      Parameters:
      className - The class
      Returns:
      All known subclasses
    • getKnownDirectImplementors

      Collection<ClassInfo> getKnownDirectImplementors(DotName className)
      Gets all known direct implementors of the specified interface name. A known direct implementor is one which was found during the scanning process; however, this is often not the complete universe of implementors, since typically indexes are constructed per jar. It is expected that several indexes will need to be searched when analyzing a jar that is a part of a complex multi-module/classloader environment (like an EE application server).

      The list of implementors may also include other methodParameters, in order to get a complete list of all classes that are assignable to a given interface it is necessary to recursively call getKnownDirectImplementors(DotName) for every implementing interface found.

      Parameters:
      className - the super class of the desired subclasses
      Returns:
      a non-null list of all known subclasses of className
    • getAllKnownImplementors

      Collection<ClassInfo> getAllKnownImplementors(DotName interfaceName)
      Returns all known classes that implement the given interface, directly and indirectly. This will all return classes that implement sub methodParameters of the interface, and sub-classes of classes that implement the interface. (In short, it will return every class that is assignable to the interface that is found in the index)

      This will only return classes, not methodParameters.

      Parameters:
      interfaceName - The interface
      Returns:
      All known implementors of the interface
    • getAnnotations

      Collection<AnnotationInstance> getAnnotations(DotName annotationName)
      Obtains a list of instances for the specified annotation. This is done using an O(1) lookup. Valid instance targets include field, method, parameter, and class.
      Parameters:
      annotationName - the name of the annotation to look for
      Returns:
      a non-null list of annotation instances
    • getAnnotationsWithRepeatable

      Collection<AnnotationInstance> getAnnotationsWithRepeatable(DotName annotationName, IndexView index)
      Obtains a list of instances for the specified annotation. If the specified annotation is repeatable (JLS 9.6), the result also contains all values from all instances of the container annotation. In this case, the AnnotationInstance.target() returns the target of the container annotation instance.
      Parameters:
      annotationName - the name of the repeatable annotation
      index - the index containing the annotation class
      Returns:
      a non-null list of annotation instances
      Throws:
      IllegalArgumentException - If the the defining annotation class is not found
      IllegalArgumentException - If the index does not contain the annotation definition or if it does not represent an annotation type
    • getKnownModules

      Collection<ModuleInfo> getKnownModules()
      Gets all known modules by this index (those which were scanned).
      Returns:
      a collection of known modules
    • getModuleByName

      ModuleInfo getModuleByName(DotName moduleName)
      Gets the module that was scanned during the indexing phase.
      Parameters:
      moduleName - the name of the module
      Returns:
      information about the module or null if it is not known
    • getKnownUsers

      Collection<ClassInfo> getKnownUsers(DotName className)
      Obtains a list of classes that use the specified class. In other words, a list of classes that include a reference to the specified class in their constant pool.
      Parameters:
      className - the name of the class to look for
      Returns:
      a non-null list of classes that use the specified class