public final class Index extends Object implements IndexView
DotName values.
It contains the following information:
| Modifier and Type | Method and Description |
|---|---|
static Index |
create(Map<DotName,List<AnnotationInstance>> annotations,
Map<DotName,List<ClassInfo>> subclasses,
Map<DotName,List<ClassInfo>> implementors,
Map<DotName,ClassInfo> classes)
Constructs a "mock" Index using the passed values.
|
static Index |
create(Map<DotName,List<AnnotationInstance>> annotations,
Map<DotName,List<ClassInfo>> subclasses,
Map<DotName,List<ClassInfo>> implementors,
Map<DotName,ClassInfo> classes,
Map<DotName,List<ClassInfo>> users)
Constructs a "mock" Index using the passed values.
|
static Index |
create(Map<DotName,List<AnnotationInstance>> annotations,
Map<DotName,List<ClassInfo>> subclasses,
Map<DotName,List<ClassInfo>> subinterfaces,
Map<DotName,List<ClassInfo>> implementors,
Map<DotName,ClassInfo> classes,
Map<DotName,List<ClassInfo>> users)
Constructs a "mock" Index using the passed values.
|
Set<ClassInfo> |
getAllKnownImplementors(DotName interfaceName)
Returns all known classes that implement the given interface, directly and indirectly.
|
Collection<ClassInfo> |
getAllKnownSubclasses(DotName className)
Returns all known (including non-direct) subclasses of the given class.
|
Collection<ClassInfo> |
getAllKnownSubinterfaces(DotName interfaceName)
Returns all known interfaces that extend the given interface, directly and indirectly.
|
List<AnnotationInstance> |
getAnnotations(DotName annotationName)
Obtains a list of instances for the specified annotation.
|
Collection<AnnotationInstance> |
getAnnotationsWithRepeatable(DotName annotationName,
IndexView index)
Obtains a list of instances for the specified annotation.
|
ClassInfo |
getClassByName(DotName className)
Gets the class (or interface, or annotation) that was scanned during the
indexing phase.
|
Collection<ClassInfo> |
getClassesInPackage(DotName packageName)
Returns all classes known to this index that are present in given package.
|
Collection<ClassInfo> |
getKnownClasses()
Gets all known classes by this index (those which were scanned).
|
List<ClassInfo> |
getKnownDirectImplementors(DotName className)
Gets all known direct implementors of the specified interface.
|
List<ClassInfo> |
getKnownDirectSubclasses(DotName className)
Gets all known direct subclasses of the specified class.
|
List<ClassInfo> |
getKnownDirectSubinterfaces(DotName interfaceName)
Gets all known direct subinterfaces of the specified interface.
|
Collection<ModuleInfo> |
getKnownModules()
Gets all known modules by this index (those which were scanned).
|
List<ClassInfo> |
getKnownUsers(DotName className)
Obtains a list of classes that use the specified class.
|
ModuleInfo |
getModuleByName(DotName moduleName)
Gets the module that was scanned during the indexing phase.
|
Set<DotName> |
getSubpackages(DotName packageName)
Returns a set of packages known to this index that are direct subpackages of given package.
|
static Index |
of(Class<?>... classes)
Constructs an Index of the passed classes.
|
static Index |
of(File... files)
Constructs an Index of the passed files and directories.
|
static Index |
of(Iterable<Class<?>> classes)
Constructs an Index of the passed classes.
|
void |
printAnnotations()
Print all annotations known by this index to stdout.
|
void |
printSubclasses()
Print all classes that have known subclasses, and all their subclasses
|
static ClassInfo |
singleClass(byte[] classData)
|
static ClassInfo |
singleClass(Class<?> clazz)
|
static ClassInfo |
singleClass(InputStream classData)
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetAllKnownImplementors, getAllKnownImplementors, getAllKnownSubclasses, getAllKnownSubclasses, getAllKnownSubinterfaces, getAllKnownSubinterfaces, getAnnotations, getAnnotations, getAnnotationsWithRepeatable, getAnnotationsWithRepeatable, getClassByName, getClassByName, getClassesInPackage, getKnownDirectImplementors, getKnownDirectImplementors, getKnownDirectSubclasses, getKnownDirectSubclasses, getKnownDirectSubinterfaces, getKnownDirectSubinterfaces, getKnownUsers, getKnownUsers, getModuleByName, getSubpackagespublic static Index create(Map<DotName,List<AnnotationInstance>> annotations, Map<DotName,List<ClassInfo>> subclasses, Map<DotName,List<ClassInfo>> implementors, Map<DotName,ClassInfo> classes)
annotations - A map to lookup annotation instances by class namesubclasses - A map to lookup subclasses by super class nameimplementors - A map to lookup implementing classes by interface nameclasses - A map to lookup classes by class namepublic static Index create(Map<DotName,List<AnnotationInstance>> annotations, Map<DotName,List<ClassInfo>> subclasses, Map<DotName,List<ClassInfo>> implementors, Map<DotName,ClassInfo> classes, Map<DotName,List<ClassInfo>> users)
annotations - A map to lookup annotation instances by class namesubclasses - A map to lookup subclasses by super class nameimplementors - A map to lookup implementing classes by interface nameclasses - A map to lookup classes by class nameusers - A map to lookup class userspublic static Index create(Map<DotName,List<AnnotationInstance>> annotations, Map<DotName,List<ClassInfo>> subclasses, Map<DotName,List<ClassInfo>> subinterfaces, Map<DotName,List<ClassInfo>> implementors, Map<DotName,ClassInfo> classes, Map<DotName,List<ClassInfo>> users)
annotations - A map to lookup annotation instances by class namesubclasses - A map to lookup subclasses by super class namesubinterfaces - A map to lookup subinterfaces by super interface nameimplementors - A map to lookup implementing classes by interface nameclasses - A map to lookup classes by class nameusers - A map to lookup class userspublic static Index of(Iterable<Class<?>> classes) throws IOException
classes - Classes to indexIOExceptionpublic static Index of(Class<?>... classes) throws IOException
classes - Classes to indexIOExceptionpublic static Index of(File... files) throws IOException
files - class files, JAR files or directories containing class files to indexIllegalArgumentException - if any passed File is null or not a class file, JAR file or directoryIOExceptionpublic static ClassInfo singleClass(Class<?> clazz) throws IOException
clazz - the class to index, must not be nullClassInfoIOExceptionpublic static ClassInfo singleClass(byte[] classData) throws IOException
classData - the class bytecode to index, must not be nullClassInfoIOExceptionpublic static ClassInfo singleClass(InputStream classData) throws IOException
Indexer, indexes given classData, and returns
the corresponding ClassInfo. Closing the input stream is the caller's
responsibility.classData - the class bytecode to index, must not be nullClassInfoIOExceptionpublic List<AnnotationInstance> getAnnotations(DotName annotationName)
getAnnotations in interface IndexViewannotationName - the name of the annotation to look forpublic Collection<AnnotationInstance> getAnnotationsWithRepeatable(DotName annotationName, IndexView index)
AnnotationInstance.target() returns the target of the container annotation instance.getAnnotationsWithRepeatable in interface IndexViewannotationName - the name of the repeatable annotationindex - the index containing the annotation classpublic List<ClassInfo> getKnownDirectSubclasses(DotName className)
Note that this will only pick up direct subclasses of the class. It will not pick up subclasses of subclasses.
getKnownDirectSubclasses in interface IndexViewclassName - the super class of the desired subclassespublic Collection<ClassInfo> getAllKnownSubclasses(DotName className)
IndexViewgetAllKnownSubclasses in interface IndexViewclassName - The classpublic List<ClassInfo> getKnownDirectSubinterfaces(DotName interfaceName)
Note that this will only pick up direct subinterfaces of the interface. It will not pick up subinterfaces of subinterfaces.
getKnownDirectSubinterfaces in interface IndexViewinterfaceName - the super interface of the desired subinterfacespublic Collection<ClassInfo> getAllKnownSubinterfaces(DotName interfaceName)
getAllKnownSubinterfaces in interface IndexViewinterfaceName - The interacepublic List<ClassInfo> getKnownDirectImplementors(DotName className)
The list of implementors also includes direct subinterfaces. This is inconsistent
with IndexView.getAllKnownImplementors(DotName), which doesn't return subinterfaces.
Note that this will only pick up classes that directly implement given interface. It will not pick up classes implementing subinterfaces.
getKnownDirectImplementors in interface IndexViewclassName - the super class of the desired subclassespublic Set<ClassInfo> getAllKnownImplementors(DotName interfaceName)
Note that this method only returns classes. Unlike IndexView.getKnownDirectImplementors(DotName),
this method does not return subinterfaces of given interface.
getAllKnownImplementors in interface IndexViewinterfaceName - The interfacepublic ClassInfo getClassByName(DotName className)
getClassByName in interface IndexViewclassName - the name of the classpublic Collection<ClassInfo> getKnownClasses()
getKnownClasses in interface IndexViewpublic Collection<ModuleInfo> getKnownModules()
getKnownModules in interface IndexViewpublic ModuleInfo getModuleByName(DotName moduleName)
getModuleByName in interface IndexViewmoduleName - the name of the modulepublic List<ClassInfo> getKnownUsers(DotName className)
getKnownUsers in interface IndexViewclassName - the name of the class to look forpublic Collection<ClassInfo> getClassesInPackage(DotName packageName)
IndexViewnull as the package name. If this index does not contain
any class in given package, returns an empty collection.
In the default Index implementation, this information is not stored in the index initially.
Instead, an index of classes by package name is constructed on demand (on the first invocation
of this method).
getClassesInPackage in interface IndexViewpackageName - package name in the common, dot-separated form (e.g. com.example.foobar);
null means the unnamed packagenullpublic Set<DotName> getSubpackages(DotName packageName)
IndexView
Given that the unnamed package may not contain subpackages, passing null as the package
name is permitted, but always results in an empty set.
In the default Index implementation, this information is not stored in the index initially.
Instead, an index of packages is constructed on demand (on the first invocation of this method).
getSubpackages in interface IndexViewpackageName - package name in the common, dot-separated form (e.g. com.example.foobar);
null means the unnamed packagenullpublic void printAnnotations()
public void printSubclasses()
Copyright © 2018–2022. All rights reserved.