/** * Reads in from an existing AnnotatedType. Any elements not present are * added. The javaClass will be read in. If the annotation already exists on * that element in the builder the read annotation will be used. * * @param type the type to read from * @throws IllegalArgumentException if type is null */ public AnnotatedTypeBuilder<X> readFromType(AnnotatedType<X> type) { return readFromType(type, true); }
/** * Reads the annotations from an existing java type. Annotations already * present will be overwritten * * @param type the type to read from * @throws IllegalArgumentException if type is null */ public AnnotatedTypeBuilder<X> readFromType(Class<X> type) { return readFromType(type, true); }
/** * Reads in from an existing AnnotatedType. Any elements not present are * added. The javaClass will be read in. If the annotation already exists on * that element in the builder the read annotation will be used. * * @param type the type to read from * @throws IllegalArgumentException if type is null */ public AnnotatedTypeBuilder<X> readFromType(AnnotatedType<X> type) { return readFromType(type, true); }
/** * Reads the annotations from an existing java type. Annotations already * present will be overwritten * * @param type the type to read from * @throws IllegalArgumentException if type is null */ public AnnotatedTypeBuilder<X> readFromType(Class<X> type) { return readFromType(type, true); }
/** * Reads the annotations from an existing java type. Annotations already * present will be overwritten * * @param type the type to read from * @throws IllegalArgumentException if type is null */ public AnnotatedTypeBuilder<X> readFromType(Class<X> type) { return readFromType(type, true); }
/** * Reads in from an existing AnnotatedType. Any elements not present are * added. The javaClass will be read in. If the annotation already exists on * that element in the builder the read annotation will be used. * * @param type the type to read from * @throws IllegalArgumentException if type is null */ public AnnotatedTypeBuilder<X> readFromType(AnnotatedType<X> type) { return readFromType(type, true); }
ActivatableAlternativeBuilder(ProcessAnnotatedType<X> pat) { this.pat = pat; type = pat.getAnnotatedType(); javaClass = type.getJavaClass(); builder = new AnnotatedTypeBuilder<>(); builder.readFromType(type); }
<T> void processAnnotatedType(@Observes ProcessAnnotatedType<T> pat) { final AnnotatedType<T> annotatedType = pat.getAnnotatedType(); if (annotatedType.getJavaClass().equals(testClass)) { AnnotatedTypeBuilder<T> builder = new AnnotatedTypeBuilder<T>().readFromType(annotatedType).addToClass(APPLICATIONSCOPED); pat.setAnnotatedType(builder.create()); } }
<T> void processAnnotatedType(@Observes ProcessAnnotatedType<T> pat) { final AnnotatedType<T> annotatedType = pat.getAnnotatedType(); if (annotatedType.getJavaClass().equals(testClass)) { AnnotatedTypeBuilder<T> builder = new AnnotatedTypeBuilder<T>().readFromType(annotatedType).addToClass(APPLICATIONSCOPED); pat.setAnnotatedType(builder.create()); } }
<T> void processAnnotatedType(@Observes ProcessAnnotatedType<T> pat) { final AnnotatedType<T> annotatedType = pat.getAnnotatedType(); if (annotatedType.getJavaClass().equals(testClass)) { AnnotatedTypeBuilder<T> builder = new AnnotatedTypeBuilder<T>().readFromType(annotatedType).addToClass(APPLICATIONSCOPED); pat.setAnnotatedType(builder.create()); } }
<T> void processAnnotatedType(@Observes ProcessAnnotatedType<T> pat) { final AnnotatedType<T> annotatedType = pat.getAnnotatedType(); if (annotatedType.getJavaClass().equals(testClass)) { AnnotatedTypeBuilder<T> builder = new AnnotatedTypeBuilder<T>().readFromType(annotatedType).addToClass(APPLICATIONSCOPED); pat.setAnnotatedType(builder.create()); } }
@SuppressWarnings("serial") public <T> void processAnnotatedType( @Observes @WithAnnotations(Path.class) ProcessAnnotatedType<T> processAnnotatedType) { AnnotatedTypeBuilder<T> builder = new AnnotatedTypeBuilder<T>() .readFromType(processAnnotatedType.getAnnotatedType()) .addToClass(new AnnotationLiteral<Exceptionable>() {}); processAnnotatedType.setAnnotatedType(builder.create()); }
public <T> void processAuthenticationServiceTypes(@Observes final ProcessAnnotatedType<T> processedAnnotatedType) { final Class<T> type = processedAnnotatedType.getAnnotatedType().getJavaClass(); if (isNonKeycloakAuthenticationService(type)) { processedAnnotatedType.setAnnotatedType(new AnnotatedTypeBuilder<T>() .readFromType(processedAnnotatedType.getAnnotatedType()).removeFromClass(Default.class) .addToClass(wrapped).create()); } }
/** * Add an annotation to the class represented by pat. * * @param pat ProcessAnnotatedType for bean. * @param annotation annotation literal to add to the type. * @param <X> any type. */ public static <X> void addClassAnnotation(ProcessAnnotatedType<X> pat, Annotation annotation) { AnnotatedTypeBuilder<X> builder = new AnnotatedTypeBuilder<>(); builder.readFromType(pat.getAnnotatedType()); pat.setAnnotatedType(builder.addToClass(annotation).create()); } }
public <T> void onAnnotatedType(@Observes @WithAnnotations(Transactional.class) ProcessAnnotatedType<T> annotatedType) { AnnotatedTypeBuilder<T> builder = new AnnotatedTypeBuilder<T>() .readFromType(annotatedType.getAnnotatedType()) .addToClass(AnnotationInstanceProvider.of(org.apache.deltaspike.jpa.api.transaction.Transactional.class)); annotatedType.setAnnotatedType(builder.create()); }
@Test public void buildValidAnnotationAnnotatedType() { final AnnotatedTypeBuilder<Small> builder = new AnnotatedTypeBuilder<Small>(); builder.readFromType(Small.class); final AnnotatedType<Small> smallAnnotatedType = builder.create(); assertThat(smallAnnotatedType.getMethods().size(), is(1)); assertThat(smallAnnotatedType.getConstructors().size(), is(0)); assertThat(smallAnnotatedType.getFields().size(), is(0)); }
private <X> void createEJBWrapper(ProcessAnnotatedType<X> pat, final AnnotatedType<X> at) { EjbAsynchronous ejbAsynchronous = AnnotationInstanceProvider.of(EjbAsynchronous.class); EjbTransactional transactionalAnnotation = AnnotationInstanceProvider.of(EjbTransactional.class); AnnotatedTypeBuilder<X> builder = new AnnotatedTypeBuilder<X>().readFromType(at); builder.addToClass(transactionalAnnotation); if (possiblyAsynchronous(at)) { builder.addToClass(ejbAsynchronous); } // by annotating let CDI set Wrapper to this Bean pat.setAnnotatedType(builder.create()); }
@Test public void testCtWithMultipleParams() { final AnnotatedTypeBuilder<TypeWithParamsInCt> builder = new AnnotatedTypeBuilder<TypeWithParamsInCt>(); builder.readFromType(TypeWithParamsInCt.class); builder.addToClass(new AnnotationLiteral<Default>() {}); AnnotatedType<TypeWithParamsInCt> newAt = builder.create(); assertNotNull(newAt); }
@Test public void testAdditionOfAnnotation() { final AnnotatedTypeBuilder<Cat> builder = new AnnotatedTypeBuilder<Cat>(); builder.readFromType(Cat.class, true); builder.addToClass(new TypedLiteral()); final AnnotatedType<Cat> catAnnotatedType = builder.create(); assertThat(catAnnotatedType.isAnnotationPresent(Typed.class), is(true)); }
@Test public void testEnumWithParam() { final AnnotatedTypeBuilder<EnumWithParams> builder = new AnnotatedTypeBuilder<EnumWithParams>(); builder.readFromType(EnumWithParams.class); builder.addToClass(new AnnotationLiteral<Default>() {}); AnnotatedType<EnumWithParams> newAt = builder.create(); assertNotNull(newAt); }