use of javax.enterprise.inject.spi.AnnotatedParameter in project deltaspike by apache.
the class AnnotatedTypeBuilderTest method modifyAnnotationsOnConstructorParameter.
@Test
public void modifyAnnotationsOnConstructorParameter() throws NoSuchMethodException {
final AnnotatedTypeBuilder<Cat> builder = new AnnotatedTypeBuilder<Cat>();
builder.readFromType(Cat.class, true);
builder.removeFromConstructorParameter(Cat.class.getConstructor(String.class, String.class), 1, Default.class);
builder.addToConstructorParameter(Cat.class.getConstructor(String.class, String.class), 1, new AnyLiteral());
final AnnotatedType<Cat> catAnnotatedType = builder.create();
Set<AnnotatedConstructor<Cat>> catCtors = catAnnotatedType.getConstructors();
assertThat(catCtors.size(), is(2));
for (AnnotatedConstructor<Cat> ctor : catCtors) {
if (ctor.getParameters().size() == 2) {
List<AnnotatedParameter<Cat>> ctorParams = ctor.getParameters();
assertThat(ctorParams.get(1).getAnnotations().size(), is(1));
assertThat((AnyLiteral) ctorParams.get(1).getAnnotations().toArray()[0], is(new AnyLiteral()));
}
}
}
use of javax.enterprise.inject.spi.AnnotatedParameter in project deltaspike by apache.
the class AnnotatedCallableImpl method getAnnotatedParameters.
private static <X, Y extends Member> List<AnnotatedParameter<X>> getAnnotatedParameters(AnnotatedCallableImpl<X, Y> callable, Class<?>[] parameterTypes, Type[] genericTypes, Map<Integer, AnnotationStore> parameterAnnotations, Map<Integer, Type> parameterTypeOverrides) {
List<AnnotatedParameter<X>> parameters = new ArrayList<AnnotatedParameter<X>>();
int len = parameterTypes.length;
for (int i = 0; i < len; ++i) {
AnnotationBuilder builder = new AnnotationBuilder();
if (parameterAnnotations != null && parameterAnnotations.containsKey(i)) {
builder.addAll(parameterAnnotations.get(i));
}
Type over = null;
if (parameterTypeOverrides != null) {
over = parameterTypeOverrides.get(i);
}
AnnotatedParameterImpl<X> p = new AnnotatedParameterImpl<X>(callable, parameterTypes[i], i, builder.create(), genericTypes[i], over);
parameters.add(p);
}
return parameters;
}
Aggregations