public class ClassInfo extends Object implements Comparable<ClassInfo>
Modifier and Type | Method and Description |
---|---|
boolean |
annotatesClass(String annotatedClassName)
Test whether this class annotates the named class.
|
boolean |
annotatesFieldOfClass(String className)
Test whether this annotation annotates a field of the named class.
|
boolean |
annotatesMethodOfClass(String className)
Test whether this annotation annotates or meta-annotates a method of the named class.
|
int |
compareTo(ClassInfo o)
Compare based on class name.
|
boolean |
directlyAnnotatesClass(String directlyAnnotatedClassName)
Test whether this class annotates the named class.
|
boolean |
directlyImplementsInterface(String interfaceName)
Test whether this standard class directly implements the named interface, or by one of its superclasses.
|
boolean |
equals(Object obj)
Use class name for equals().
|
List<AnnotationInfo.AnnotationParamValue> |
getAnnotationDefaultParamValues()
Get a list of the default parameter values, if this is an annotation, and it has default parameter values.
|
List<AnnotationInfo> |
getAnnotationInfo()
Get a list of annotations on this method, along with any annotation parameter values, wrapped in
AnnotationInfo objects, or the empty list if none.
|
Set<ClassInfo> |
getAnnotations()
Get the annotations and meta-annotations on this class.
|
Set<ClassInfo> |
getAnnotationsWithDirectMetaAnnotation()
Get the annotations that have this direct meta-annotation.
|
Set<ClassInfo> |
getAnnotationsWithMetaAnnotation()
Get the annotations that have this meta-annotation.
|
Set<ClassInfo> |
getClassesDirectlyImplementing()
Get the classes that directly implement this interface, and their subclasses.
|
Set<ClassInfo> |
getClassesImplementing()
Get the classes that implement this interface, and their subclasses.
|
Set<ClassInfo> |
getClassesWithAnnotation()
Get the standard classes and non-annotation interfaces that are annotated by this annotation.
|
Set<ClassInfo> |
getClassesWithDirectAnnotation()
Get the standard classes or non-annotation interfaces that are directly annotated with this annotation.
|
Set<ClassInfo> |
getClassesWithDirectFieldAnnotation()
Get the classes that have a field with this direct annotation.
|
Set<ClassInfo> |
getClassesWithDirectMethodAnnotation()
Get the classes that have a method with this direct annotation.
|
Set<ClassInfo> |
getClassesWithFieldAnnotation()
Get the classes that have a field with this annotation or meta-annotation.
|
Set<ClassInfo> |
getClassesWithMethodAnnotation()
Get the classes that have a method with this annotation or meta-annotation.
|
ClassLoader[] |
getClassLoaders()
Get the ClassLoader(s) to use when trying to load the class.
|
int |
getClassModifiers()
Get the class modifier flags, e.g.
|
String |
getClassName()
Get the name of this class.
|
static List<String> |
getClassNames(Collection<ClassInfo> classInfoColl)
Get the sorted list of the names of classes given a collection of ClassInfo objects.
|
URL |
getClasspathElementURL()
The classpath element URL (classpath root dir or jar) that this class was found within.
|
Set<URL> |
getClasspathElementURLs()
The classpath element URL(s) (classpath root dir or jar) that this class was found within.
|
List<MethodInfo> |
getConstructorInfo()
Returns information on visible constructors of the class.
|
Set<ClassInfo> |
getDirectAnnotations()
Get the direct annotations and meta-annotations on this class.
|
Set<ClassInfo> |
getDirectlyImplementedInterfaces()
Get the interfaces directly implemented by this standard class.
|
Set<ClassInfo> |
getDirectSubclasses()
Get the direct subclasses of this class.
|
Set<ClassInfo> |
getDirectSubinterfaces()
Get the direct subinterfaces of this interface.
|
ClassInfo |
getDirectSuperclass()
Convenience method for getting the single direct superclass of this class.
|
Set<ClassInfo> |
getDirectSuperclasses()
Get the direct superclasses of this class.
|
Set<ClassInfo> |
getDirectSuperinterfaces()
Get the direct superinterfaces of this interface.
|
Set<ClassInfo> |
getFieldAnnotations()
Get the field annotations on this class.
|
List<FieldInfo> |
getFieldInfo()
Returns information on all visible fields of the class.
|
FieldInfo |
getFieldInfo(String fieldName)
Returns information on a given visible field of the class.
|
Set<ClassInfo> |
getFieldTypes()
Get the types of this class' fields.
|
String |
getFullyQualifiedContainingMethodName()
Get fully-qualified containing method name (i.e.
|
Set<ClassInfo> |
getImplementedInterfaces()
Get the interfaces implemented by this standard class, or by one of its superclasses.
|
Set<ClassInfo> |
getInnerClasses()
Returns the inner classes contained within this class.
|
List<String> |
getInnerClassNames()
Returns the names of inner classes contained within this class.
|
Set<ClassInfo> |
getMetaAnnotations()
Get the annotations and meta-annotations on this annotation class.
|
List<MethodInfo> |
getMethodAndConstructorInfo()
Returns information on visible methods and constructors of the class.
|
Set<ClassInfo> |
getMethodAnnotations()
Get the method annotations or meta-annotations on this class.
|
Set<ClassInfo> |
getMethodDirectAnnotations()
Get the direct method direct annotations on this class.
|
List<MethodInfo> |
getMethodInfo()
Returns information on visible methods of the class that are not constructors.
|
List<MethodInfo> |
getMethodInfo(String methodName)
Returns information on the method(s) of the class with the given method name.
|
String |
getNameOfDirectSuperclass()
Convenience method for getting the name of the single direct superclass of this class.
|
List<String> |
getNamesOfAnnotations()
Get the names of annotations and meta-annotations on this class.
|
List<String> |
getNamesOfAnnotationsWithDirectMetaAnnotation()
Get the names of annotations that have this direct meta-annotation.
|
List<String> |
getNamesOfAnnotationsWithMetaAnnotation()
Get the names of annotations that have this meta-annotation.
|
List<String> |
getNamesOfClassesDirectlyImplementing()
Get the names of classes that directly implement this interface, and the names of their subclasses.
|
List<String> |
getNamesOfClassesImplementing()
Get the names of classes that implement this interface, and the names of their subclasses.
|
List<String> |
getNamesOfClassesWithAnnotation()
Get the names of standard classes and non-annotation interfaces that are annotated by this annotation.
|
List<String> |
getNamesOfClassesWithDirectAnnotation()
Get the names of standard classes or non-annotation interfaces that are directly annotated with this
annotation.
|
List<String> |
getNamesOfClassesWithDirectFieldAnnotation()
Get the names of classes that have a field with this direct annotation.
|
List<String> |
getNamesOfClassesWithDirectMethodAnnotation()
Get the names of classes that have a method with this direct annotation.
|
List<String> |
getNamesOfClassesWithFieldAnnotation()
Get the names of classes that have a field with this annotation or meta-annotation.
|
List<String> |
getNamesOfClassesWithMethodAnnotation()
Get the names of classes that have a method with this annotation.
|
List<String> |
getNamesOfDirectAnnotations()
Get the names of direct annotations and meta-annotations on this class.
|
List<String> |
getNamesOfDirectlyImplementedInterfaces()
Get the interfaces directly implemented by this standard class, or by one of its superclasses.
|
List<String> |
getNamesOfDirectSubclasses()
Get the names of direct subclasses of this class.
|
List<String> |
getNamesOfDirectSubinterfaces()
Get the names of direct subinterfaces of this interface.
|
List<String> |
getNamesOfDirectSuperclasses()
Get the names of direct superclasses of this class.
|
List<String> |
getNamesOfDirectSuperinterfaces()
Get the names of direct superinterfaces of this interface.
|
List<String> |
getNamesOfFieldAnnotations()
Get the names of field annotations on this class.
|
List<String> |
getNamesOfFieldTypes()
Get the names of the types of this class' fields.
|
List<String> |
getNamesOfImplementedInterfaces()
Get the interfaces implemented by this standard class, or by one of its superclasses.
|
List<String> |
getNamesOfMetaAnnotations()
Get the names of annotations and meta-annotations on this annotation class.
|
List<String> |
getNamesOfMethodAnnotations()
Get the names of method annotations or meta-annotations on this class.
|
List<String> |
getNamesOfMethodDirectAnnotations()
Get the names of method direct annotations on this class.
|
List<String> |
getNamesOfSubclasses()
Get the names of subclasses of this class.
|
List<String> |
getNamesOfSubinterfaces()
Get the names of subinterfaces of this interface.
|
List<String> |
getNamesOfSuperclasses()
Get the names of all direct and indirect superclasses of this class (i.e.
|
List<String> |
getNamesOfSuperinterfaces()
Get the names of superinterfaces of this interface.
|
Set<ClassInfo> |
getOuterClasses()
Returns the containing outer classes, for inner classes.
|
List<String> |
getOuterClassName()
Returns the names of the containing outer classes, for inner classes.
|
Set<ClassInfo> |
getSubclasses()
Get the subclasses of this class.
|
Set<ClassInfo> |
getSubinterfaces()
Get the subinterfaces of this interface.
|
Set<ClassInfo> |
getSuperclasses()
Get all direct and indirect superclasses of this class (i.e.
|
Set<ClassInfo> |
getSuperinterfaces()
Get the superinterfaces of this interface.
|
boolean |
hasAnnotation(String annotationName)
Test whether this class, interface or annotation has the named class annotation or meta-annotation.
|
boolean |
hasDirectAnnotation(String directAnnotationName)
Test whether this class has the named direct annotation or meta-annotation.
|
boolean |
hasDirectMetaAnnotation(String directMetaAnnotationName)
Test whether this annotation is directly meta-annotated with the named annotation.
|
boolean |
hasDirectSubclass(String directSubclassName)
Test whether this class has the named direct subclass.
|
boolean |
hasDirectSubinterface(String directSubinterfaceName)
Test whether this class is and interface and has the named direct subinterface.
|
boolean |
hasDirectSuperclass(String directSuperclassName)
Test whether this class directly extends the named superclass.
|
boolean |
hasDirectSuperinterface(String directSuperinterfaceName)
Test whether this class is an interface and has the named direct superinterface.
|
boolean |
hasFieldWithAnnotation(String annotationName)
Test whether this class has a field with the named field annotation.
|
int |
hashCode()
Use hash code of class name.
|
boolean |
hasMetaAnnotation(String metaAnnotationName)
Test whether this is an annotation class and it has the named meta-annotation.
|
boolean |
hasMethodWithAnnotation(String annotationName)
Test whether this class has a method with the named method annotation or meta-annotation.
|
boolean |
hasMethodWithDirectAnnotation(String annotationName)
Test whether this class has a method with the named method direct annotation.
|
boolean |
hasSubclass(String subclassName)
Test whether this class has the named class as a subclass.
|
boolean |
hasSubinterface(String subinterfaceName)
Test whether this class is has the named subinterface.
|
boolean |
hasSuperclass(String superclassName)
Test whether this class extends the named superclass, directly or indirectly.
|
boolean |
hasSuperinterface(String superinterfaceName)
Test whether this class is an interface and has the named superinterface.
|
boolean |
implementsInterface(String interfaceName)
Test whether this standard class implements the named interface, or by one of its superclasses.
|
boolean |
isAnnotation()
Test whether this classInfo is an annotation.
|
boolean |
isAnonymousInnerClass()
Returns true if this is an anonymous inner class.
|
boolean |
isDirectlyImplementedByClass(String className)
Test whether this class is directly implemented by the named class, or by one of its superclasses.
|
boolean |
isImplementedByClass(String className)
Test whether this class is implemented by the named class, or by one of its superclasses.
|
boolean |
isImplementedInterface()
Test whether this class is an "implemented interface" (meaning a standard, non-annotation interface, or an
annotation that has also been implemented as an interface by some class).
|
boolean |
isInnerClass()
Returns true if this is an inner class (call isAnonymousInnerClass() to test if this is an anonymous inner
class).
|
boolean |
isOuterClass()
Returns true if this class contains inner classes.
|
boolean |
isStandardClass()
Test whether this class is a standard class (not an annotation or interface).
|
boolean |
metaAnnotatesAnnotation(String annotationName)
Test whether this annotation has the named meta-annotation.
|
String |
toString() |
public String getClassName()
public int getClassModifiers()
public Set<URL> getClasspathElementURLs()
For Scala, it is possible (though not likely) that a class and its companion class will be provided in different jars or different directories, so to be safe, for Scala, you should probably call this method instead.
public URL getClasspathElementURL()
(If calling this from Scala, in the rare but possible case that a class and its companion class is split between two jarfiles or directories, this will throw IllegalArgumentException.)
public ClassLoader[] getClassLoaders()
public int compareTo(ClassInfo o)
compareTo
in interface Comparable<ClassInfo>
public boolean equals(Object obj)
public static List<String> getClassNames(Collection<ClassInfo> classInfoColl)
public boolean isStandardClass()
public Set<ClassInfo> getSubclasses()
public List<String> getNamesOfSubclasses()
public boolean hasSubclass(String subclassName)
public Set<ClassInfo> getDirectSubclasses()
public List<String> getNamesOfDirectSubclasses()
public boolean hasDirectSubclass(String directSubclassName)
public Set<ClassInfo> getSuperclasses()
(Includes the union of all mixin superclass hierarchies in the case of Scala mixins.)
public List<String> getNamesOfSuperclasses()
(Includes the union of all mixin superclass hierarchies in the case of Scala mixins.)
public boolean hasSuperclass(String superclassName)
public boolean isInnerClass()
public Set<ClassInfo> getOuterClasses()
public List<String> getOuterClassName()
public boolean isOuterClass()
public Set<ClassInfo> getInnerClasses()
public List<String> getInnerClassNames()
public boolean isAnonymousInnerClass()
public String getFullyQualifiedContainingMethodName()
public Set<ClassInfo> getDirectSuperclasses()
Typically the returned set will contain zero or one direct superclass(es), but may contain more than one direct superclass in the case of Scala mixins.
public ClassInfo getDirectSuperclass()
IllegalArgumentException
- if there are multiple direct superclasses of this class (in the case of Scala mixins).public List<String> getNamesOfDirectSuperclasses()
Typically the returned list will contain zero or one direct superclass name(s), but may contain more than one direct superclass name in the case of Scala mixins.
public String getNameOfDirectSuperclass()
IllegalArgumentException
- if there are multiple direct superclasses of this class (in the case of Scala mixins).public boolean hasDirectSuperclass(String directSuperclassName)
If this class has multiple direct superclasses (in the case of Scala mixins), returns true if the named superclass is one of the direct superclasses of this class.
directSuperclassName
- The direct superclass name to match. If null, matches classes without a direct superclass (e.g.
interfaces). Note that standard classes that do not extend another class have java.lang.Object as
their superclass.public boolean isImplementedInterface()
Annotations are interfaces, but you can also implement an annotation, so to we Test whether an interface (even an annotation) is implemented by a class or extended by a subinterface, or (failing that) if it is not an interface but not an annotation.
(This is named "implemented interface" rather than just "interface" to distinguish it from an annotation.)
public Set<ClassInfo> getSubinterfaces()
public List<String> getNamesOfSubinterfaces()
public boolean hasSubinterface(String subinterfaceName)
public Set<ClassInfo> getDirectSubinterfaces()
public List<String> getNamesOfDirectSubinterfaces()
public boolean hasDirectSubinterface(String directSubinterfaceName)
public Set<ClassInfo> getSuperinterfaces()
public List<String> getNamesOfSuperinterfaces()
public boolean hasSuperinterface(String superinterfaceName)
public Set<ClassInfo> getDirectSuperinterfaces()
public List<String> getNamesOfDirectSuperinterfaces()
public boolean hasDirectSuperinterface(String directSuperinterfaceName)
public Set<ClassInfo> getImplementedInterfaces()
public List<String> getNamesOfImplementedInterfaces()
public boolean implementsInterface(String interfaceName)
public Set<ClassInfo> getDirectlyImplementedInterfaces()
public List<String> getNamesOfDirectlyImplementedInterfaces()
public boolean directlyImplementsInterface(String interfaceName)
public Set<ClassInfo> getClassesImplementing()
public List<String> getNamesOfClassesImplementing()
public boolean isImplementedByClass(String className)
public Set<ClassInfo> getClassesDirectlyImplementing()
public List<String> getNamesOfClassesDirectlyImplementing()
public boolean isDirectlyImplementedByClass(String className)
public boolean isAnnotation()
public Set<ClassInfo> getClassesWithAnnotation()
public List<String> getNamesOfClassesWithAnnotation()
public boolean annotatesClass(String annotatedClassName)
public Set<ClassInfo> getClassesWithDirectAnnotation()
public List<String> getNamesOfClassesWithDirectAnnotation()
public boolean directlyAnnotatesClass(String directlyAnnotatedClassName)
public Set<ClassInfo> getAnnotations()
public List<String> getNamesOfAnnotations()
public boolean hasAnnotation(String annotationName)
public List<AnnotationInfo> getAnnotationInfo()
public List<AnnotationInfo.AnnotationParamValue> getAnnotationDefaultParamValues()
public Set<ClassInfo> getDirectAnnotations()
public List<String> getNamesOfDirectAnnotations()
public boolean hasDirectAnnotation(String directAnnotationName)
public Set<ClassInfo> getMetaAnnotations()
public List<String> getNamesOfMetaAnnotations()
public boolean hasMetaAnnotation(String metaAnnotationName)
public Set<ClassInfo> getAnnotationsWithMetaAnnotation()
public List<String> getNamesOfAnnotationsWithMetaAnnotation()
public boolean metaAnnotatesAnnotation(String annotationName)
public Set<ClassInfo> getAnnotationsWithDirectMetaAnnotation()
public List<String> getNamesOfAnnotationsWithDirectMetaAnnotation()
public boolean hasDirectMetaAnnotation(String directMetaAnnotationName)
public List<MethodInfo> getMethodInfo()
Requires that FastClasspathScanner#enableMethodInfo() be called before scanning, otherwise throws IllegalArgumentException.
By default only returns information for public methods, unless FastClasspathScanner#ignoreMethodVisibility()
was called before the scan. If method visibility is ignored, the result may include a reference to a private
static class initializer block, with a method name of "<clinit>"
.
IllegalArgumentException
- if FastClasspathScanner#enableMethodInfo() was not called prior to initiating the scan.public List<MethodInfo> getConstructorInfo()
"<init>"
. There may be more than one constructor of a given name with different type signatures, due
to overloading.
Requires that FastClasspathScanner#enableMethodInfo() be called before scanning, otherwise throws IllegalArgumentException.
By default only returns information for public constructors, unless FastClasspathScanner#ignoreMethodVisibility() was called before the scan.
IllegalArgumentException
- if FastClasspathScanner#enableMethodInfo() was not called prior to initiating the scan.public List<MethodInfo> getMethodAndConstructorInfo()
"<init>"
.
Requires that FastClasspathScanner#enableMethodInfo() be called before scanning, otherwise throws IllegalArgumentException.
By default only returns information for public methods and constructors, unless
FastClasspathScanner#ignoreMethodVisibility() was called before the scan. If method visibility is ignored,
the result may include a reference to a private static class initializer block, with a method name of
"<clinit>"
.
IllegalArgumentException
- if FastClasspathScanner#enableMethodInfo() was not called prior to initiating the scan.public List<MethodInfo> getMethodInfo(String methodName)
"<init>"
.
Requires that FastClasspathScanner#enableMethodInfo() be called before scanning, otherwise throws IllegalArgumentException.
By default only returns information for public methods, unless FastClasspathScanner#ignoreMethodVisibility() was called before the scan.
May return info for multiple methods with the same name (with different type signatures).
methodName
- The method name to query.IllegalArgumentException
- if FastClasspathScanner#enableMethodInfo() was not called prior to initiating the scan.public Set<ClassInfo> getMethodDirectAnnotations()
public Set<ClassInfo> getMethodAnnotations()
public List<String> getNamesOfMethodDirectAnnotations()
public List<String> getNamesOfMethodAnnotations()
public boolean hasMethodWithDirectAnnotation(String annotationName)
public boolean hasMethodWithAnnotation(String annotationName)
public Set<ClassInfo> getClassesWithDirectMethodAnnotation()
public Set<ClassInfo> getClassesWithMethodAnnotation()
public List<String> getNamesOfClassesWithDirectMethodAnnotation()
public List<String> getNamesOfClassesWithMethodAnnotation()
public boolean annotatesMethodOfClass(String className)
public Set<ClassInfo> getFieldTypes()
public List<String> getNamesOfFieldTypes()
public List<FieldInfo> getFieldInfo()
Requires that FastClasspathScanner#enableFieldInfo() be called before scanning, otherwise throws IllegalArgumentException.
By default only returns information for public methods, unless FastClasspathScanner#ignoreFieldVisibility() was called before the scan.
IllegalArgumentException
- if FastClasspathScanner#enableFieldInfo() was not called prior to initiating the scan.public FieldInfo getFieldInfo(String fieldName)
Requires that FastClasspathScanner#enableFieldInfo() be called before scanning, otherwise throws IllegalArgumentException.
By default only returns information for public fields, unless FastClasspathScanner#ignoreFieldVisibility() was called before the scan.
fieldName
- The field name to query.IllegalArgumentException
- if FastClasspathScanner#enableFieldInfo() was not called prior to initiating the scan.public Set<ClassInfo> getFieldAnnotations()
public List<String> getNamesOfFieldAnnotations()
public boolean hasFieldWithAnnotation(String annotationName)
public Set<ClassInfo> getClassesWithFieldAnnotation()
public List<String> getNamesOfClassesWithFieldAnnotation()
public Set<ClassInfo> getClassesWithDirectFieldAnnotation()
public List<String> getNamesOfClassesWithDirectFieldAnnotation()
public boolean annotatesFieldOfClass(String className)
Copyright © 2018. All rights reserved.