public class ScanResult extends Object
Modifier and Type | Method | Description |
---|---|---|
List<Class<?>> |
classNamesToClassRefs(List<String> classNames) |
Produce a list of Class references given a list of class names.
|
List<Class<?>> |
classNamesToClassRefs(List<String> classNames,
boolean ignoreExceptions) |
Produce a list of Class references given a list of class names.
|
<T> List<Class<T>> |
classNamesToClassRefs(List<String> classNames,
Class<T> commonClassType) |
Produce a list of Class references, given a list of names of classes extending a common superclass or
implementing a common interface.
|
<T> List<Class<T>> |
classNamesToClassRefs(List<String> classNames,
Class<T> commonClassType,
boolean ignoreExceptions) |
Produce a list of Class references, given a list of names of classes extending a common superclass or
implementing a common interface.
|
Class<?> |
classNameToClassRef(String className) |
Produce Class reference given a class name.
|
Class<?> |
classNameToClassRef(String className,
boolean ignoreExceptions) |
Produce Class reference given a class name.
|
<T> Class<T> |
classNameToClassRef(String className,
Class<T> classType) |
Produce Class reference given a class name.
|
<T> Class<T> |
classNameToClassRef(String className,
Class<T> classType,
boolean ignoreExceptions) |
Produce Class reference given a class name.
|
long |
classpathContentsLastModifiedTime() |
Find the maximum last-modified timestamp of any whitelisted file/directory/jarfile encountered during the
scan.
|
boolean |
classpathContentsModifiedSinceScan() |
Determine whether the classpath contents have been modified since the last scan.
|
protected void |
finalize() |
|
void |
freeTempFiles(LogNode log) |
Free any temporary files created by extracting jars from within jars.
|
static ScanResult |
fromJSON(String json) |
Deserialize a ScanResult from previously-saved JSON.
|
String |
generateClassGraphDotFile() |
Generate a .dot file which can be fed into GraphViz for layout and visualization of the class graph.
|
String |
generateClassGraphDotFile(float sizeX,
float sizeY) |
Generate a .dot file which can be fed into GraphViz for layout and visualization of the class graph.
|
String |
generateClassGraphDotFile(float sizeX,
float sizeY,
boolean showFields,
boolean showMethods) |
Generate a .dot file which can be fed into GraphViz for layout and visualization of the class graph.
|
ClassLoader[] |
getClassLoadersForClass(String className) |
Find the classloader(s) for the named class.
|
Map<String,ClassInfo> |
getClassNameToClassInfo() |
Get a map from class name to ClassInfo object for all whitelisted classes found during the scan.
|
List<Throwable> |
getMatchProcessorExceptions() |
Return the exceptions and errors thrown during classloading and/or while calling MatchProcessors on loaded
classes.
|
List<String> |
getNamesOfAllAnnotationClasses() |
Get the names of all annotation classes found during the scan.
|
List<String> |
getNamesOfAllClasses() |
Get the names of all classes, interfaces and annotations found during the scan.
|
List<String> |
getNamesOfAllInterfaceClasses() |
Get the names of all interface classes found during the scan.
|
List<String> |
getNamesOfAllStandardClasses() |
Get the names of all standard (non-interface/non-annotation) classes found during the scan.
|
List<String> |
getNamesOfAnnotationsOnClass(Class<?> klass) |
Get the names of all annotations and meta-annotations on the given class.
|
List<String> |
getNamesOfAnnotationsOnClass(String className) |
Get the names of all annotations and meta-annotations on the named class.
|
List<String> |
getNamesOfAnnotationsWithMetaAnnotation(Class<?> metaAnnotation) |
Return the names of all annotations that have the named meta-annotation.
|
List<String> |
getNamesOfAnnotationsWithMetaAnnotation(String metaAnnotationName) |
Return the names of all annotations that have the named meta-annotation.
|
List<String> |
getNamesOfClassesImplementing(Class<?> implementedInterface) |
Get the names of all classes that implement (or have superclasses that implement) the given interface (or one
of its subinterfaces).
|
List<String> |
getNamesOfClassesImplementing(String interfaceName) |
Get the names of all classes that implement (or have superclasses that implement) the named interface (or one
of its subinterfaces).
|
List<String> |
getNamesOfClassesImplementingAllOf(Class<?>... implementedInterfaces) |
Get the names of all classes that implement (or have superclasses that implement) all of the given interfaces
(or their subinterfaces).
|
List<String> |
getNamesOfClassesImplementingAllOf(String... implementedInterfaceNames) |
Get the names of all classes that implement (or have superclasses that implement) all of the named interfaces
(or their subinterfaces).
|
List<String> |
getNamesOfClassesWithAnnotation(Class<?> annotation) |
Get the names of non-annotation classes with the given class annotation or meta-annotation.
|
List<String> |
getNamesOfClassesWithAnnotation(String annotationName) |
Get the names of non-annotation classes with the named class annotation or meta-annotation.
|
List<String> |
getNamesOfClassesWithAnnotationsAllOf(Class<?>... annotations) |
Get the names of classes that have all of the given annotations.
|
List<String> |
getNamesOfClassesWithAnnotationsAllOf(String... annotationNames) |
Get the names of classes that have all of the named annotations.
|
List<String> |
getNamesOfClassesWithAnnotationsAnyOf(Class<?>... annotations) |
Get the names of classes that have any of the given annotations.
|
List<String> |
getNamesOfClassesWithAnnotationsAnyOf(String... annotationNames) |
Get the names of classes that have any of the named annotations.
|
List<String> |
getNamesOfClassesWithFieldAnnotation(Class<?> annotation) |
Get the names of classes that have a field with an annotation of the given type.
|
List<String> |
getNamesOfClassesWithFieldAnnotation(String annotationName) |
Get the names of classes that have a field with an annotation of the named type.
|
List<String> |
getNamesOfClassesWithMethodAnnotation(Class<?> annotation) |
Get the names of classes that have a method with an annotation of the given type.
|
List<String> |
getNamesOfClassesWithMethodAnnotation(String annotationName) |
Get the names of classes that have a method with an annotation of the named type.
|
List<String> |
getNamesOfSubclassesOf(Class<?> superclass) |
Get the names of classes on the classpath that extend the specified superclass.
|
List<String> |
getNamesOfSubclassesOf(String superclassName) |
Get the names of all subclasses of the named class.
|
List<String> |
getNamesOfSubinterfacesOf(Class<?> superInterface) |
Get the names of interfaces on the classpath that extend a given superinterface.
|
List<String> |
getNamesOfSubinterfacesOf(String interfaceName) |
Get the names of all subinterfaces of the named interface.
|
List<String> |
getNamesOfSuperclassesOf(Class<?> subclass) |
Get the names of classes on the classpath that are superclasses of the specified subclass.
|
List<String> |
getNamesOfSuperclassesOf(String subclassName) |
Get the names of classes on the classpath that are superclasses of the named subclass.
|
List<String> |
getNamesOfSuperinterfacesOf(Class<?> subInterface) |
Get the names of all superinterfaces of the given subinterface.
|
List<String> |
getNamesOfSuperinterfacesOf(String subInterfaceName) |
Get the names of all superinterfaces of the named interface.
|
List<File> |
getUniqueClasspathElements() |
Returns the list of File objects for unique classpath elements (directories or jarfiles), in classloader
resolution order.
|
String |
getUniqueClasspathElementsAsPathStr() |
Returns all unique directories or zip/jarfiles on the classpath, in classloader resolution order, as a
classpath string, delineated with the standard path separator character.
|
List<URL> |
getUniqueClasspathElementURLs() |
Returns the list of unique classpath element paths as URLs, in classloader resolution order.
|
String |
toJSON() |
Serialize a ScanResult to minified (un-indented) JSON.
|
String |
toJSON(int indentWidth) |
Serialize a ScanResult to JSON.
|
public ClassLoader[] getClassLoadersForClass(String className)
className
- The class name.public List<Throwable> getMatchProcessorExceptions()
public List<File> getUniqueClasspathElements()
public String getUniqueClasspathElementsAsPathStr()
public List<URL> getUniqueClasspathElementURLs()
public boolean classpathContentsModifiedSinceScan()
public long classpathContentsLastModifiedTime()
This method cannot in general tell if classpath has changed (or modules have been added or removed) if it is run twice during the same runtime session.
public Map<String,ClassInfo> getClassNameToClassInfo()
https://github.com/lukehutch/fast-classpath-scanner/wiki/1.-Usage#mechanism-3
public List<String> getNamesOfAllClasses()
public List<String> getNamesOfAllStandardClasses()
public List<String> getNamesOfSubclassesOf(String superclassName)
superclassName
- The name of the superclass.public List<String> getNamesOfSubclassesOf(Class<?> superclass)
superclass
- The superclass to match (i.e. the class that subclasses need to extend to match).public List<String> getNamesOfSuperclassesOf(String subclassName)
subclassName
- The name of the subclass.public List<String> getNamesOfSuperclassesOf(Class<?> subclass)
subclass
- The subclass to match (i.e. the class that needs to extend a superclass for the superclass to
match).public List<String> getNamesOfClassesWithMethodAnnotation(String annotationName)
annotationName
- the name of the method annotation.public List<String> getNamesOfClassesWithMethodAnnotation(Class<?> annotation)
annotation
- the method annotation.public List<String> getNamesOfClassesWithFieldAnnotation(String annotationName)
annotationName
- the name of the field annotation.public List<String> getNamesOfClassesWithFieldAnnotation(Class<?> annotation)
annotation
- the field annotation.public List<String> getNamesOfAllInterfaceClasses()
public List<String> getNamesOfSubinterfacesOf(String interfaceName)
interfaceName
- The interface name.public List<String> getNamesOfSubinterfacesOf(Class<?> superInterface)
superInterface
- The superinterface.public List<String> getNamesOfSuperinterfacesOf(String subInterfaceName)
subInterfaceName
- The subinterface name.public List<String> getNamesOfSuperinterfacesOf(Class<?> subInterface)
subInterface
- The subinterface.public List<String> getNamesOfClassesImplementing(String interfaceName)
interfaceName
- The interface name.public List<String> getNamesOfClassesImplementing(Class<?> implementedInterface)
implementedInterface
- The interface.public List<String> getNamesOfClassesImplementingAllOf(String... implementedInterfaceNames)
implementedInterfaceNames
- The names of the interfaces.public List<String> getNamesOfClassesImplementingAllOf(Class<?>... implementedInterfaces)
implementedInterfaces
- The interfaces.public List<String> getNamesOfAllAnnotationClasses()
public List<String> getNamesOfClassesWithAnnotation(String annotationName)
annotationName
- The name of the class annotation or meta-annotation.public List<String> getNamesOfClassesWithAnnotation(Class<?> annotation)
annotation
- The class annotation or meta-annotation to match.public List<String> getNamesOfClassesWithAnnotationsAllOf(String... annotationNames)
annotationNames
- The class annotation names.public List<String> getNamesOfClassesWithAnnotationsAllOf(Class<?>... annotations)
annotations
- The class annotations.public List<String> getNamesOfClassesWithAnnotationsAnyOf(String... annotationNames)
annotationNames
- The annotation names.public List<String> getNamesOfClassesWithAnnotationsAnyOf(Class<?>... annotations)
annotations
- The annotations.public List<String> getNamesOfAnnotationsOnClass(String className)
className
- The class name.public List<String> getNamesOfAnnotationsOnClass(Class<?> klass)
klass
- The class.public List<String> getNamesOfAnnotationsWithMetaAnnotation(String metaAnnotationName)
metaAnnotationName
- The name of the meta-annotation.public List<String> getNamesOfAnnotationsWithMetaAnnotation(Class<?> metaAnnotation)
metaAnnotation
- The meta-annotation.public String generateClassGraphDotFile(float sizeX, float sizeY, boolean showFields, boolean showMethods)
Note that if you call this with showFields or showMethods set to false, but with method and/or field info enabled during scanning, then arrows will still be added between classes even if the field or method that created that dependency is not shown.
sizeX
- The GraphViz layout width in inches.sizeY
- The GraphViz layout width in inches.showFields
- If true, show fields within class nodes in the graph. To show field info,
FastClasspathScanner.enableFieldInfo()
should be
called before scanning. You may also want to call
FastClasspathScanner.ignoreFieldVisibility()
before scanning, to show non-public fields.showMethods
- If true, show methods within class nodes in the graph. To show method info,
FastClasspathScanner.enableMethodInfo()
should be
called before scanning. You may also want to call
FastClasspathScanner.ignoreMethodVisibility()
before scanning, to show non-public methods.public String generateClassGraphDotFile(float sizeX, float sizeY)
FastClasspathScanner.enableMethodInfo()
and
FastClasspathScanner.enableFieldInfo()
. Only public
methods/fields are shown, unless
FastClasspathScanner.ignoreMethodVisibility()
and/or
FastClasspathScanner.ignoreFieldVisibility()
has been
called. The sizeX and sizeY parameters are the image output size to use (in inches) when GraphViz is asked to
render the .dot file.sizeX
- The GraphViz layout width in inches.sizeY
- The GraphViz layout width in inches.public String generateClassGraphDotFile()
FastClasspathScanner.enableMethodInfo()
and
FastClasspathScanner.enableFieldInfo()
. Only public
methods/fields are shown, unless
FastClasspathScanner.ignoreMethodVisibility()
and/or
FastClasspathScanner.ignoreFieldVisibility()
has been
called. The size defaults to 10.5 x 8 inches.public List<Class<?>> classNamesToClassRefs(List<String> classNames, boolean ignoreExceptions) throws IllegalArgumentException
Enable verbose scanning to see details of any exceptions thrown during classloading, even if ignoreExceptions is false.
classNames
- The list of names of classes to load.ignoreExceptions
- If true, exceptions are ignored during classloading, otherwise IllegalArgumentException is thrown
if a class could not be loaded.IllegalArgumentException
- if ignoreExceptions is false, IllegalArgumentException is thrown if there were problems loading
or initializing the classes. (Note that class initialization on load is disabled by default, you
can enable it with FastClasspathScanner#initializeLoadedClasses(true)
.) Otherwise
exceptions are suppressed, and classes are not added to the resulting list if loading them
exhibits any of these problems.public <T> List<Class<T>> classNamesToClassRefs(List<String> classNames, Class<T> commonClassType, boolean ignoreExceptions) throws IllegalArgumentException
Enable verbose scanning to see details of any exceptions thrown during classloading, even if ignoreExceptions is false.
classNames
- The list of names of classes to load.commonClassType
- The common superclass of, or interface implemented by, the named classes.ignoreExceptions
- If true, exceptions are ignored during classloading, otherwise IllegalArgumentException is thrown
if a class could not be loaded.IllegalArgumentException
- if ignoreExceptions is false, IllegalArgumentException is thrown if there were problems loading
the classes, initializing the classes, or casting them to the requested type. (Note that class
initialization on load is disabled by default, you can enable it with
FastClasspathScanner#initializeLoadedClasses(true)
.) Otherwise exceptions are
suppressed, and classes are not added to the resulting list if loading them exhibits any of these
problems.public List<Class<?>> classNamesToClassRefs(List<String> classNames) throws IllegalArgumentException
classNames
- The list of names of classes to load.IllegalArgumentException
- if there were problems loading or initializing the classes. (Note that class initialization on
load is disabled by default, you can enable it with
FastClasspathScanner#initializeLoadedClasses(true)
.)public <T> List<Class<T>> classNamesToClassRefs(List<String> classNames, Class<T> commonClassType) throws IllegalArgumentException
classNames
- The list of names of classes to load.commonClassType
- The common superclass of, or interface implemented by, the named classes.IllegalArgumentException
- if there were problems loading the classes, initializing the classes, or casting them to the
requested type. (Note that class initialization on load is disabled by default, you can enable it
with FastClasspathScanner#initializeLoadedClasses(true)
.)public Class<?> classNameToClassRef(String className, boolean ignoreExceptions) throws IllegalArgumentException
Enable verbose scanning to see details of any exceptions thrown during classloading, even if ignoreExceptions is false.
className
- The names of the class to load.ignoreExceptions
- If true, null is returned if there was an exception during classloading, otherwise
IllegalArgumentException is thrown if a class could not be loaded.IllegalArgumentException
- if ignoreExceptions is false, IllegalArgumentException is thrown if there were problems loading
or initializing the class. (Note that class initialization on load is disabled by default, you
can enable it with FastClasspathScanner#initializeLoadedClasses(true)
.) Otherwise
exceptions are suppressed, and null is returned if any of these problems occurs.public <T> Class<T> classNameToClassRef(String className, Class<T> classType, boolean ignoreExceptions) throws IllegalArgumentException
Enable verbose scanning to see details of any exceptions thrown during classloading, even if ignoreExceptions is false.
className
- The names of the class to load.classType
- The class type to cast the result to.ignoreExceptions
- If true, null is returned if there was an exception during classloading, otherwise
IllegalArgumentException is thrown if a class could not be loaded.IllegalArgumentException
- if ignoreExceptions is false, IllegalArgumentException is thrown if there were problems loading
the class, initializing the class, or casting it to the requested type. (Note that class
initialization on load is disabled by default, you can enable it with
FastClasspathScanner#initializeLoadedClasses(true)
.) Otherwise exceptions are
suppressed, and null is returned if any of these problems occurs.public Class<?> classNameToClassRef(String className) throws IllegalArgumentException
Enable verbose scanning to see details of any exceptions thrown during classloading, even if ignoreExceptions is false.
className
- The names of the classe to load.IllegalArgumentException
- if there were problems loading or initializing the class. (Note that class initialization on load
is disabled by default, you can enable it with
FastClasspathScanner#initializeLoadedClasses(true)
.)public <T> Class<T> classNameToClassRef(String className, Class<T> classType) throws IllegalArgumentException
Enable verbose scanning to see details of any exceptions thrown during classloading, even if ignoreExceptions is false.
className
- The names of the classe to load.classType
- The class type to cast the result to.IllegalArgumentException
- if there were problems loading the class, initializing the class, or casting it to the requested
type. (Note that class initialization on load is disabled by default, you can enable it with
FastClasspathScanner#initializeLoadedClasses(true)
.)public static ScanResult fromJSON(String json)
public String toJSON(int indentWidth)
indentWidth
- If greater than 0, JSON will be formatted (indented), otherwise it will be minified (un-indented).public String toJSON()
public void freeTempFiles(LogNode log)
log
- The log.Copyright © 2018. All rights reserved.