/** * Add an annotation to the specified constructor. If the constructor is not * already present, it will be added. * * @param constructor the constructor to add the annotation to * @param annotation the annotation to add * @throws IllegalArgumentException if the annotation is null */ public AnnotatedTypeBuilder<X> addToConstructor(AnnotatedConstructor<X> constructor, Annotation annotation) { return addToConstructor(constructor.getJavaMember(), annotation); }
void applyQualifier(Annotation qual, AnnotatedTypeBuilder<?> atb) { AnnotatedType<?> at = atb.create(); //do a loop on all field to replace annotation mark by CDI annotations for (AnnotatedField af : at.getFields()) if (af.isAnnotationPresent(InjectWithQualifier.class)) { atb.addToField(af, InjectLiteral.instance); atb.addToField(af, qual); } //loop on constructors to do the same for (AnnotatedConstructor ac : at.getConstructors()) { Annotation[][] pa = ac.getJavaMember().getParameterAnnotations(); //loop on args to detect marked param for (int i = 0; i < pa.length; i++) for (int j = 0; j < pa[i].length; j++) if (pa[i][j].equals(InjectWithQualifierLiteral.instance)) { atb.addToConstructor(ac, InjectLiteral.instance); atb.addToConstructorParameter(ac.getJavaMember(), i, qual); } } //loop on other methods (setters) for (AnnotatedMethod am : at.getMethods()) if (am.isAnnotationPresent(InjectWithQualifierLiteral.class)) { atb.addToMethod(am, InjectLiteral.instance); atb.addToMethod(am, qual); } }
/** * Add an annotation to the specified constructor. If the constructor is not * already present, it will be added. * * @param constructor the constructor to add the annotation to * @param annotation the annotation to add * @throws IllegalArgumentException if the annotation is null */ public AnnotatedTypeBuilder<X> addToConstructor(AnnotatedConstructor<X> constructor, Annotation annotation) { return addToConstructor(constructor.getJavaMember(), annotation); }
/** * Add an annotation to the specified constructor. If the constructor is not * already present, it will be added. * * @param constructor the constructor to add the annotation to * @param annotation the annotation to add * @throws IllegalArgumentException if the annotation is null */ public AnnotatedTypeBuilder<X> addToConstructor(AnnotatedConstructor<X> constructor, Annotation annotation) { return addToConstructor(constructor.getJavaMember(), annotation); }