void observesCountrysidePAT(@Observes ProcessAnnotatedType<Countryside> event) { AnnotatedConstructorConfigurator<Countryside> annotatedConstructorConfigurator = event.configureAnnotatedType() .filterConstructors(constructor -> constructor.isAnnotationPresent(Inject.class)).findFirst().get(); //add qualifier to each constructor param annotatedConstructorConfigurator.params().forEach(annotatedParam -> annotatedParam.add(Wild.WildLiteral.INSTANCE)); }
void observesDogDependenciesProducerPAT(@Observes ProcessAnnotatedType<DogDependenciesProducer> event) { AnnotatedTypeConfigurator<DogDependenciesProducer> annotatedTypeConfigurator = event.configureAnnotatedType(); // add @Produces and @Created to DogDependenciesProducer.produceFeed getAMConfiguratorByName(annotatedTypeConfigurator, "produceFeed").add(ProducesLiteral.INSTANCE) .add(Dogs.DogsLiteral.INSTANCE); // add @Produces and @Created to DogDependenciesProducer.dogName annotatedTypeConfigurator.filterFields(af -> af.getJavaMember().getName().equals("dogName")).findFirst().get().add(ProducesLiteral.INSTANCE) .add(Dogs.DogsLiteral.INSTANCE); // add @Disposes to DogDependenciesProducer.disposeFeed getAMConfiguratorByName(annotatedTypeConfigurator, "disposeFeed") .filterParams(ap -> ap.getPosition() == 0).findFirst().get().add(DisposesLiteral.INSTANCE).add(Dogs.DogsLiteral.INSTANCE); }
void observesDogPAT(@Observes ProcessAnnotatedType<Dog> event) { annotatedTypesEqual.set(AnnotatedTypes.compareAnnotatedTypes(event.configureAnnotatedType().getAnnotated(), event.getAnnotatedType())); AnnotatedTypeConfigurator<Dog> annotatedTypeConfigurator = event.configureAnnotatedType(); // add @RequestScoped to Dog and @Inject and @Dogs to its Feed field annotatedTypeConfigurator.add(RequestScoped.Literal.INSTANCE) .filterFields(af -> (af.getJavaMember() .getName().equals("feed"))).findFirst().get().add(InjectLiteral.INSTANCE).add(Dogs.DogsLiteral.INSTANCE); // add @Inject to Dog constructor and @Dogs to its param annotatedTypeConfigurator.constructors().iterator().next().add(InjectLiteral.INSTANCE) .filterParams(ap -> ap.getPosition() == 0).findFirst().get().add(Dogs.DogsLiteral.INSTANCE); }
if (id != null) { m.filterParams(p -> p.isAnnotationPresent(Observes.class)).findFirst().ifPresent(param -> { param.add(id); LOGGER.debug("Add id qualifier {0} to parameter {1}", id, param.getAnnotated()); });