/** * Add an annotation to the type declaration. * * @param annotation the annotation instance to add * @throws IllegalArgumentException if the annotation is null */ public AnnotatedTypeBuilder<X> addToClass(Annotation annotation) { typeAnnotations.add(annotation); return this; }
public AnnotationBuilder addAll(Set<Annotation> annotations) { for (Annotation annotation : annotations) { add(annotation); } return this; }
public AnnotationBuilder addAll(AnnotatedElement element) { for (Annotation a : element.getAnnotations()) { add(a); } return this; }
public AnnotationBuilder addAll(AnnotationStore annotations) { for (Annotation annotation : annotations.getAnnotations()) { add(annotation); } return this; }
/** * 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(Constructor<X> constructor, Annotation annotation) { if (constructors.get(constructor) == null) { constructors.put(constructor, new AnnotationBuilder()); } constructors.get(constructor).add(annotation); return this; }
/** * Add an annotation to the specified field. If the field is not already * present, it will be added. * * @param field the field to add the annotation to * @param annotation the annotation to add * @throws IllegalArgumentException if the annotation is null */ public AnnotatedTypeBuilder<X> addToField(Field field, Annotation annotation) { if (fields.get(field) == null) { fields.put(field, new AnnotationBuilder()); } fields.get(field).add(annotation); return this; }
/** * Add an annotation to the specified method. If the method is not already * present, it will be added. * * @param method the method to add the annotation to * @param annotation the annotation to add * @throws IllegalArgumentException if the annotation is null */ public AnnotatedTypeBuilder<X> addToMethod(Method method, Annotation annotation) { if (methods.get(method) == null) { methods.put(method, new AnnotationBuilder()); } methods.get(method).add(annotation); return this; }
protected void mergeAnnotationsOnElement(Annotated annotated, boolean overwriteExisting, AnnotationBuilder typeAnnotations) { for (Annotation annotation : annotated.getAnnotations()) { if (typeAnnotations.getAnnotation(annotation.annotationType()) != null) { if (overwriteExisting) { typeAnnotations.remove(annotation.annotationType()); typeAnnotations.add(annotation); } } else { typeAnnotations.add(annotation); } } }
/** * Add an annotation to the specified constructor parameter. If the * constructor is not already present, it will be added. If the constructor * parameter is not already present, it will be added. * * @param method the constructor to add the annotation to * @param position the position of the parameter to add * @param annotation the annotation to add * @throws IllegalArgumentException if the annotation is null */ public AnnotatedTypeBuilder<X> addToConstructorParameter(Constructor<X> constructor, int position, Annotation annotation) { if (!constructors.containsKey(constructor)) { constructors.put(constructor, new AnnotationBuilder()); } if (constructorParameters.get(constructor) == null) { constructorParameters.put(constructor, new HashMap<Integer, AnnotationBuilder>()); } if (constructorParameters.get(constructor).get(position) == null) { constructorParameters.get(constructor).put(position, new AnnotationBuilder()); } constructorParameters.get(constructor).get(position).add(annotation); return this; }
/** * Add an annotation to the specified method parameter. If the method is not * already present, it will be added. If the method parameter is not already * present, it will be added. * * @param method the method to add the annotation to * @param position the position of the parameter to add * @param annotation the annotation to add * @throws IllegalArgumentException if the annotation is null */ public AnnotatedTypeBuilder<X> addToMethodParameter(Method method, int position, Annotation annotation) { if (!methods.containsKey(method)) { methods.put(method, new AnnotationBuilder()); } if (methodParameters.get(method) == null) { methodParameters.put(method, new HashMap<Integer, AnnotationBuilder>()); } if (methodParameters.get(method).get(position) == null) { methodParameters.get(method).put(position, new AnnotationBuilder()); } methodParameters.get(method).get(position).add(annotation); return this; }
public void redefine(RedefinitionContext<Generic> ctx) { // if it is a parameter annotation if (!(ctx.getAnnotatedElement() instanceof AccessibleObject)) { // stick an InjectGeneric as a marker. ctx.getAnnotationBuilder().remove(Generic.class).add(InjectGenericLiteral.INSTANCE); if (ctx.getRawType().isAnnotationPresent(GenericConfiguration.class)) { ctx.getAnnotationBuilder().add(genericBeanQualifier); } } } });
public void redefine(RedefinitionContext<Inject> ctx) { if (ctx.getAnnotatedElement() instanceof Field) { if (ctx.getAnnotatedElement().isAnnotationPresent(Generic.class)) { // This is a Generic bean injection point ctx.getAnnotationBuilder().remove(Inject.class).add(InjectGenericLiteral.INSTANCE); } } }