public class AnnotationMetadataReadingVisitor extends ClassVisitor implements AnnotationMetadata
AnnotationMetadata interface.| Modifier and Type | Field and Description |
|---|---|
protected Set<String> |
annotationSet |
protected LinkedMultiValueMap<String,AnnotationAttributes> |
attributesMap
Declared as a
LinkedMultiValueMap instead of a MultiValueMap
to ensure that the hierarchical ordering of the entries is preserved. |
protected ClassLoader |
classLoader |
protected Map<String,Set<String>> |
metaAnnotationMap |
protected Set<MethodMetadata> |
methodMetadataSet |
api, cv| Constructor and Description |
|---|
AnnotationMetadataReadingVisitor(ClassLoader classLoader) |
| Modifier and Type | Method and Description |
|---|---|
MultiValueMap<String,Object> |
getAllAnnotationAttributes(String annotationType)
Retrieve all attributes of all annotations of the given type, if any (i.e.
|
MultiValueMap<String,Object> |
getAllAnnotationAttributes(String annotationType,
boolean classValuesAsString)
Retrieve all attributes of all annotations of the given type, if any (i.e.
|
Set<MethodMetadata> |
getAnnotatedMethods(String annotationType)
Retrieve the method metadata for all methods that are annotated
(or meta-annotated) with the given annotation type.
|
AnnotationAttributes |
getAnnotationAttributes(String annotationType)
Retrieve the attributes of the annotation of the given type,
if any (i.e.
|
AnnotationAttributes |
getAnnotationAttributes(String annotationType,
boolean classValuesAsString)
Retrieve the attributes of the annotation of the given type,
if any (i.e.
|
Set<String> |
getAnnotationTypes()
Return the names of all annotation types that are present on the
underlying class.
|
String |
getClassName()
Return the name of the underlying class.
|
String |
getEnclosingClassName()
Return the name of the enclosing class of the underlying class,
or
null if the underlying class is a top-level class. |
String[] |
getInterfaceNames()
Return the names of all interfaces that the underlying class
implements, or an empty array if there are none.
|
String[] |
getMemberClassNames()
Return the names of all classes declared as members of the class represented by
this ClassMetadata object.
|
Set<String> |
getMetaAnnotationTypes(String annotationType)
Return the names of all meta-annotation types present on the
given annotation type on the underlying class.
|
String |
getSuperClassName()
Return the name of the super class of the underlying class,
or
null if there is no super class defined. |
boolean |
hasAnnotatedMethods(String annotationType)
Determine whether the underlying class has any methods that are
annotated (or meta-annotated) with the given annotation type.
|
boolean |
hasAnnotation(String annotationType)
Determine whether an annotation of the given type is present on
the underlying class.
|
boolean |
hasEnclosingClass()
Return whether the underlying class has an enclosing class
(i.e.
|
boolean |
hasMetaAnnotation(String metaAnnotationType)
Determine whether the underlying class has an annotation that is itself
annotated with the meta-annotation of the given type.
|
boolean |
hasSuperClass()
Return whether the underlying class has a super class.
|
boolean |
isAbstract()
Return whether the underlying class is marked as abstract.
|
boolean |
isAnnotated(String annotationType)
Determine whether the underlying type has an annotation or
meta-annotation of the given type defined.
|
boolean |
isConcrete()
Return whether the underlying class represents a concrete class,
i.e.
|
boolean |
isFinal()
Return whether the underlying class is marked as 'final'.
|
boolean |
isIndependent()
Determine whether the underlying class is independent,
i.e.
|
boolean |
isInterface()
Return whether the underlying class represents an interface.
|
void |
visit(int version,
int access,
String name,
String signature,
String supername,
String[] interfaces)
Visits the header of the class.
|
AnnotationVisitor |
visitAnnotation(String desc,
boolean visible)
Visits an annotation of the class.
|
void |
visitAttribute(Attribute attr)
Visits a non standard attribute of the class.
|
void |
visitEnd()
Visits the end of the class.
|
FieldVisitor |
visitField(int access,
String name,
String desc,
String signature,
Object value)
Visits a field of the class.
|
void |
visitInnerClass(String name,
String outerName,
String innerName,
int access)
Visits information about an inner class.
|
MethodVisitor |
visitMethod(int access,
String name,
String desc,
String signature,
String[] exceptions)
Visits a method of the class.
|
void |
visitOuterClass(String owner,
String name,
String desc)
Visits the enclosing class of the class.
|
void |
visitSource(String source,
String debug)
Visits the source of the class.
|
visitTypeAnnotationclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetClassName, getEnclosingClassName, getInterfaceNames, getMemberClassNames, getSuperClassName, hasEnclosingClass, hasSuperClass, isAbstract, isConcrete, isFinal, isIndependent, isInterfaceprotected final ClassLoader classLoader
protected final LinkedMultiValueMap<String,AnnotationAttributes> attributesMap
LinkedMultiValueMap instead of a MultiValueMap
to ensure that the hierarchical ordering of the entries is preserved.AnnotationReadingVisitorUtils.getMergedAnnotationAttributes(LinkedMultiValueMap, String)protected final Set<MethodMetadata> methodMetadataSet
public AnnotationMetadataReadingVisitor(ClassLoader classLoader)
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions)
ClassVisitorMethodVisitor instance (or null) each time it is called,
i.e., it should not return a previously returned visitor.access - the method's access flags (see Opcodes). This
parameter also indicates if the method is synthetic and/or
deprecated.name - the method's name.desc - the method's descriptor (see Type).signature - the method's signature. May be null if the method
parameters, return type and exceptions do not use generic
types.exceptions - the internal names of the method's exception classes (see
getInternalName). May be
null.public AnnotationVisitor visitAnnotation(String desc, boolean visible)
ClassVisitordesc - the class descriptor of the annotation class.visible - true if the annotation is visible at runtime.public Set<String> getAnnotationTypes()
AnnotationMetadatagetAnnotationTypes in interface AnnotationMetadatapublic Set<String> getMetaAnnotationTypes(String annotationType)
AnnotationMetadatagetMetaAnnotationTypes in interface AnnotationMetadataannotationType - the meta-annotation type to look forpublic boolean hasAnnotation(String annotationType)
AnnotationMetadatahasAnnotation in interface AnnotationMetadataannotationType - the annotation type to look forpublic boolean hasMetaAnnotation(String metaAnnotationType)
AnnotationMetadatahasMetaAnnotation in interface AnnotationMetadatametaAnnotationType - the meta-annotation type to look forpublic boolean isAnnotated(String annotationType)
AnnotatedTypeMetadataIf this method returns true, then
AnnotatedTypeMetadata.getAnnotationAttributes(java.lang.String) will return a non-null Map.
isAnnotated in interface AnnotatedTypeMetadataannotationType - the annotation type to look forpublic AnnotationAttributes getAnnotationAttributes(String annotationType)
AnnotatedTypeMetadatagetAnnotationAttributes in interface AnnotatedTypeMetadataannotationType - the annotation type to look fornull if no matching annotation is defined.public AnnotationAttributes getAnnotationAttributes(String annotationType, boolean classValuesAsString)
AnnotatedTypeMetadatagetAnnotationAttributes in interface AnnotatedTypeMetadataannotationType - the annotation type to look forclassValuesAsString - whether to convert class references to String
class names for exposure as values in the returned Map, instead of Class
references which might potentially have to be loaded firstnull if no matching annotation is defined.public MultiValueMap<String,Object> getAllAnnotationAttributes(String annotationType)
AnnotatedTypeMetadataclass or
method), as direct annotation or as meta-annotation).getAllAnnotationAttributes in interface AnnotatedTypeMetadataannotationType - the annotation type to look fornull if no matching annotation is defined.AnnotatedTypeMetadata.getAllAnnotationAttributes(String, boolean)public MultiValueMap<String,Object> getAllAnnotationAttributes(String annotationType, boolean classValuesAsString)
AnnotatedTypeMetadataclass or
method), as direct annotation or as meta-annotation).getAllAnnotationAttributes in interface AnnotatedTypeMetadataannotationType - the annotation type to look forclassValuesAsString - whether to convert class references to Stringnull if no matching annotation is defined.AnnotatedTypeMetadata.getAllAnnotationAttributes(String)public boolean hasAnnotatedMethods(String annotationType)
AnnotationMetadatahasAnnotatedMethods in interface AnnotationMetadatapublic Set<MethodMetadata> getAnnotatedMethods(String annotationType)
AnnotationMetadataFor any returned method, AnnotatedTypeMetadata.isAnnotated(java.lang.String) will
return true for the given annotation type.
getAnnotatedMethods in interface AnnotationMetadataannotationType - the annotation type to look forMethodMetadata for methods that have a matching
annotation. The return value will be an empty set if no methods match
the annotation type.public void visit(int version,
int access,
String name,
String signature,
String supername,
String[] interfaces)
ClassVisitorvisit in class ClassVisitorversion - the class version.access - the class's access flags (see Opcodes). This parameter
also indicates if the class is deprecated.name - the internal name of the class (see
getInternalName).signature - the signature of this class. May be null if the class
is not a generic one, and does not extend or implement generic
classes or interfaces.supername - the internal of name of the super class (see
getInternalName). For
interfaces, the super class is Object. May be
null, but only for the Object class.interfaces - the internal names of the class's interfaces (see
getInternalName). May be
null.public void visitOuterClass(String owner, String name, String desc)
ClassVisitorvisitOuterClass in class ClassVisitorowner - internal name of the enclosing class of the class.name - the name of the method that contains the class, or
null if the class is not enclosed in a method of its
enclosing class.desc - the descriptor of the method that contains the class, or
null if the class is not enclosed in a method of its
enclosing class.public void visitInnerClass(String name, String outerName, String innerName, int access)
ClassVisitorvisitInnerClass in class ClassVisitorname - the internal name of an inner class (see
getInternalName).outerName - the internal name of the class to which the inner class
belongs (see getInternalName).
May be null for not member classes.innerName - the (simple) name of the inner class inside its enclosing
class. May be null for anonymous inner classes.access - the access flags of the inner class as originally declared in
the enclosing class.public void visitSource(String source, String debug)
ClassVisitorvisitSource in class ClassVisitorsource - the name of the source file from which the class was compiled.
May be null.debug - additional debug information to compute the correspondance
between source and compiled elements of the class. May be
null.public void visitAttribute(Attribute attr)
ClassVisitorvisitAttribute in class ClassVisitorattr - an attribute.public FieldVisitor visitField(int access, String name, String desc, String signature, Object value)
ClassVisitorvisitField in class ClassVisitoraccess - the field's access flags (see Opcodes). This parameter
also indicates if the field is synthetic and/or deprecated.name - the field's name.desc - the field's descriptor (see Type).signature - the field's signature. May be null if the field's
type does not use generic types.value - the field's initial value. This parameter, which may be
null if the field does not have an initial value,
must be an Integer, a Float, a Long, a
Double or a String (for int,
float, long or String fields
respectively). This parameter is only used for static
fields. Its value is ignored for non static fields, which
must be initialized through bytecode instructions in
constructors or methods.public void visitEnd()
ClassVisitorvisitEnd in class ClassVisitorpublic String getClassName()
ClassMetadatagetClassName in interface ClassMetadatapublic boolean isInterface()
ClassMetadataisInterface in interface ClassMetadatapublic boolean isAbstract()
ClassMetadataisAbstract in interface ClassMetadatapublic boolean isConcrete()
ClassMetadataisConcrete in interface ClassMetadatapublic boolean isFinal()
ClassMetadataisFinal in interface ClassMetadatapublic boolean isIndependent()
ClassMetadataisIndependent in interface ClassMetadatapublic boolean hasEnclosingClass()
ClassMetadataIf this method returns false, then the
underlying class is a top-level class.
hasEnclosingClass in interface ClassMetadatapublic String getEnclosingClassName()
ClassMetadatanull if the underlying class is a top-level class.getEnclosingClassName in interface ClassMetadatapublic boolean hasSuperClass()
ClassMetadatahasSuperClass in interface ClassMetadatapublic String getSuperClassName()
ClassMetadatanull if there is no super class defined.getSuperClassName in interface ClassMetadatapublic String[] getInterfaceNames()
ClassMetadatagetInterfaceNames in interface ClassMetadatapublic String[] getMemberClassNames()
ClassMetadatagetMemberClassNames in interface ClassMetadata