use of org.jboss.weld.literal.NewLiteral in project core by weld.
the class ResolvableBuilder method addQualifier.
private ResolvableBuilder addQualifier(Annotation qualifier, InjectionPoint injectionPoint) {
QualifierInstance qualifierInstance = QualifierInstance.of(qualifier, store);
final Class<? extends Annotation> annotationType = qualifierInstance.getAnnotationClass();
// Handle the @New qualifier special case
if (annotationType.equals(New.class)) {
New newQualifier = New.class.cast(qualifier);
if (newQualifier.value().equals(New.class) && rawType == null) {
throw new IllegalStateException("Cannot transform @New when there is no known raw type");
} else if (newQualifier.value().equals(New.class)) {
qualifier = new NewLiteral(rawType);
qualifierInstance = QualifierInstance.of(qualifier, store);
}
} else if (injectionPoint != null && annotationType.equals(Named.class)) {
Named named = (Named) qualifier;
if (named.value().equals("")) {
// WELD-1739
// This is an injection point with an @Named qualifier, with no value specified, we need to assume the name of the field or parameter is the
// value
Member member = injectionPoint.getMember();
if (member instanceof Executable) {
// Method or constructor injection
Executable executable = (Executable) member;
AnnotatedParameter<?> annotatedParameter = (AnnotatedParameter<?>) injectionPoint.getAnnotated();
Parameter parameter = executable.getParameters()[annotatedParameter.getPosition()];
named = new NamedLiteral(parameter.getName());
} else {
named = new NamedLiteral(injectionPoint.getMember().getName());
}
qualifier = named;
qualifierInstance = QualifierInstance.of(named, store);
}
}
checkQualifier(qualifier, qualifierInstance, annotationType);
this.qualifierInstances.add(qualifierInstance);
return this;
}
Aggregations