if (DEBUG_DEFAULT_ANNOTATION) {
System.out.println("Checking for " + defaultAnnotation + " containing " + typeQualifierValue + " on " + o);
}
// - check to see if default annotation is present; if not, return null
AnnotationValue annotationValue = o.getAnnotation(defaultAnnotation);
if (annotationValue == null) {
if (DEBUG_DEFAULT_ANNOTATION) {
System.out.println(" ===> no " + defaultAnnotation);
}
return null;
}
// - get value - should be Type or array of Type
Object value = annotationValue.getValue("value");
if (value == null) {
if (DEBUG_DEFAULT_ANNOTATION) {
System.out.println(" ===> value is null");
}
return null;
}
Object[] types;
if (value instanceof Object[]) {
types = (Object[]) value;
} else {
types = new Object[] { value };
}
// - scan through array elements; see if any match the
// TypeQualifierValue (including type qualifier nicknames)
for (Object obj : types) {
if (!(obj instanceof Type)) {
if (DEBUG_DEFAULT_ANNOTATION) {
System.out
.println("Found a non-Type value in value array of " + defaultAnnotation.toString() + " annotation");
}
continue;
}
Type type = (Type) obj;
if (DEBUG_DEFAULT_ANNOTATION) {
System.out.println(" ===> checking " + type.getDescriptor());
}
if (type.getDescriptor().startsWith("[")) {
continue;
}
ClassDescriptor typeDesc = DescriptorFactory.instance().getClassDescriptor(type.getInternalName());
// There is no general way to figure out whether a particular
// type is a type qualifier we're interested in without
// resolving it.
AnnotationValue annotation = new AnnotationValue(typeDesc);
Collection<AnnotationValue> resolvedTypeQualifiers = TypeQualifierResolver.resolveTypeQualifiers(annotation);
TypeQualifierAnnotation tqa = extractAnnotation(resolvedTypeQualifiers, typeQualifierValue);
if (tqa != null) {
return tqa;
}