private List<Annotation> resolveQualifiers(Set<Annotation> annotations, BeanManager beanManager) { List<Annotation> result = new ArrayList<Annotation>(); for (Annotation annotation : annotations) { if (beanManager.isQualifier(annotation.annotationType())) { result.add(annotation); } } return result; }
private List<Annotation> resolveQualifiers(Set<Annotation> annotations, BeanManager beanManager) { List<Annotation> result = new ArrayList<Annotation>(); for (Annotation annotation : annotations) { if (beanManager.isQualifier(annotation.annotationType())) { result.add(annotation); } } return result; }
FrameworkMethodInjectionPoint(Method method, int position, BeanManager manager) { this.method = method; this.annotated = new FrameworkAnnotatedParameter(method, position, manager); this.type = method.getGenericParameterTypes()[position]; this.qualifiers = new HashSet<>(); for (Annotation annotation : method.getParameterAnnotations()[position]) { if (manager.isQualifier(annotation.annotationType())) { qualifiers.add(annotation); } } }
public Set<Annotation> getQualifiers() { return annotated.getAnnotations().stream() .filter(a -> manager.isQualifier(a.annotationType())) .collect(toSet()); }
@Override public boolean isQualifier(Class<? extends Annotation> annotationType) { return delegate().isQualifier(annotationType); }
@Test @SpecAssertion(section = BM_DETERMINING_ANNOTATION, id = "aa") public void testDetermineQualifierType() { assertTrue(getCurrentManager().isQualifier(Any.class)); assertTrue(getCurrentManager().isQualifier(Tame.class)); assertFalse(getCurrentManager().isQualifier(AnimalStereotype.class)); assertFalse(getCurrentManager().isQualifier(ApplicationScoped.class)); assertFalse(getCurrentManager().isQualifier(Transactional.class)); }
@Override public boolean isQualifier(Class<? extends Annotation> annotationType) { return delegate().isQualifier(annotationType); }
@Override public boolean isQualifier(Class<? extends Annotation> annotationType) { return delegate().isQualifier(annotationType); }
@Override public boolean isQualifier(Class<? extends Annotation> annotationType) { return delegate().isQualifier(annotationType); }
@Override public boolean isQualifier(Class<? extends Annotation> annotationType) { return delegate().isQualifier(annotationType); }
static Set<Annotation> getQualifiers(Annotated annotated, BeanManager manager) { return annotated.getAnnotations().stream() .filter(annotation -> manager.isQualifier(annotation.annotationType())) .collect(collectingAndThen(toSet(), qualifiers -> { if (qualifiers.isEmpty()) { qualifiers.add(DEFAULT); } qualifiers.add(ANY); return qualifiers; }) ); }
@Test(groups="rewrite") @SpecAssertion(section = "11.3.13", id = "aa") // Should also check a custom bindingtype public void testDetermineBindingType() { assert getCurrentManager().isQualifier(Tame.class); assert !getCurrentManager().isQualifier(AnimalStereotype.class); assert !getCurrentManager().isQualifier(ApplicationScoped.class); assert !getCurrentManager().isQualifier(Transactional.class); }
public static void validateQualifiers(Iterable<Annotation> qualifiers, BeanManager manager, Object definer, String nullErrorMessage) { if (qualifiers == null) { throw MetadataLogger.LOG.qualifiersNull(nullErrorMessage, definer); } for (Annotation annotation : qualifiers) { if (!manager.isQualifier(annotation.annotationType())) { throw MetadataLogger.LOG.notAQualifier(annotation.annotationType(), definer); } } }
public static void validateQualifiers(Iterable<Annotation> qualifiers, BeanManager manager, Object definer, String nullErrorMessage) { if (qualifiers == null) { throw MetadataLogger.LOG.qualifiersNull(nullErrorMessage, definer); } for (Annotation annotation : qualifiers) { if (!manager.isQualifier(annotation.annotationType())) { throw MetadataLogger.LOG.notAQualifier(annotation.annotationType(), definer); } } }
public static void validateQualifiers(Iterable<Annotation> qualifiers, BeanManager manager, Object definer, String nullErrorMessage) { if (qualifiers == null) { throw MetadataLogger.LOG.qualifiersNull(nullErrorMessage, definer); } for (Annotation annotation : qualifiers) { if (!manager.isQualifier(annotation.annotationType())) { throw MetadataLogger.LOG.notAQualifier(annotation.annotationType(), definer); } } }
public static void validateQualifiers(Iterable<Annotation> qualifiers, BeanManager manager, Object definer, String nullErrorMessage) { if (qualifiers == null) { throw MetadataLogger.LOG.qualifiersNull(nullErrorMessage, definer); } for (Annotation annotation : qualifiers) { if (!manager.isQualifier(annotation.annotationType())) { throw MetadataLogger.LOG.notAQualifier(annotation.annotationType(), definer); } } }
public static void validateQualifiers(Iterable<Annotation> qualifiers, BeanManager manager, Object definer, String nullErrorMessage) { if (qualifiers == null) { throw MetadataLogger.LOG.qualifiersNull(nullErrorMessage, definer); } for (Annotation annotation : qualifiers) { if (!manager.isQualifier(annotation.annotationType())) { throw MetadataLogger.LOG.notAQualifier(annotation.annotationType(), definer); } } }
public static void validateQualifiers(Iterable<Annotation> qualifiers, BeanManager manager, Object definer, String nullErrorMessage) { if (qualifiers == null) { throw MetadataLogger.LOG.qualifiersNull(nullErrorMessage, definer); } for (Annotation annotation : qualifiers) { if (!manager.isQualifier(annotation.annotationType())) { throw MetadataLogger.LOG.notAQualifier(annotation.annotationType(), definer); } } }
@SuppressWarnings("serial") @Test @SpecAssertion(section = BEFORE_BEAN_DISCOVERY, id = "ab") public void testAddingQualifierByClass() { assertTrue(BeforeBeanDiscoveryObserver.isObserved()); assertEquals(getBeans(Alligator.class).size(), 0); assertEquals(getBeans(Alligator.class, new AnnotationLiteral<Tame>() { }).size(), 1); assertTrue(getCurrentManager().isQualifier(Tame.class)); }
@Test @SpecAssertions({ @SpecAssertion(section = INIT_EVENTS, id = "be") }) public void testDecoratorIsNotApplied() { Foo payload = new Foo(false); manager.fireEvent(payload); assertTrue(fooObserver.isObserved()); assertFalse(payload.isDecorated()); assertTrue(manager.isQualifier(Default.class)); // not decorated }