public static Set<Annotation> getAllQualifiers(
AnnotatedElement annotatedGuy,
String name,
Collector collector) {
Named namedQualifier = null;
Set<Annotation> retVal = ReflectionHelper.getQualifierAnnotations(annotatedGuy);
for (Annotation anno : retVal) {
if (anno instanceof Named) {
namedQualifier = (Named) anno;
break;
}
}
if (name == null) {
if (namedQualifier != null) {
collector.addThrowable(new IllegalArgumentException("No name was in the descriptor, but this element(" +
annotatedGuy + " has a Named annotation with value: " + namedQualifier.value()));
retVal.remove(namedQualifier);
}
return retVal;
}
if (namedQualifier == null || namedQualifier.value().equals("")) {
if (namedQualifier != null) {
retVal.remove(namedQualifier);
}
namedQualifier = new NamedImpl(name);
retVal.add(namedQualifier);
}
if (!name.equals(namedQualifier.value())) {
collector.addThrowable(new IllegalArgumentException("The class had an @Named qualifier that was inconsistent." +
" The expected name is " + name +
" but the annotation has name " + namedQualifier.value()));
}
return retVal;
}