public void checkQualifierConditions()

in webbeans-impl/src/main/java/org/apache/webbeans/annotation/AnnotationManager.java [462:523]


    public void checkQualifierConditions(Annotation ann)
    {
        if (ann == DefaultLiteral.INSTANCE || ann == AnyLiteral.INSTANCE ||
            ann.annotationType().equals(Default.class) || ann.annotationType().equals(Any.class) ||
            ann.annotationType().equals(Named.class))
        {
            // special performance boost for some known Qualifiers
            return;
        }

        AnnotatedType annotatedType = webBeansContext.getBeanManagerImpl().getAdditionalAnnotatedTypeQualifiers().get(ann.annotationType());
        if (annotatedType == null)
        {
            Iterator<AnnotatedType> annotatedTypes = (Iterator)webBeansContext.getBeanManagerImpl().getAnnotatedTypes(ann.annotationType()).iterator();
            if (annotatedTypes.hasNext())
            {
                annotatedType = annotatedTypes.next();
                // TODO what to do here, if we have more than one?
            }
        }
        if (annotatedType != null)
        {
            Set<AnnotatedMethod> methods = annotatedType.getMethods();

            for (AnnotatedMethod method : methods)
            {
                Type baseType = method.getBaseType();
                Class<?> clazz = ClassUtil.getClass(baseType);
                if (clazz.isArray() || clazz.isAnnotation())
                {
                    if (!AnnotationUtil.hasAnnotation(method.getAnnotations(), Nonbinding.class))
                    {
                        throw new WebBeansConfigurationException("WebBeans definition class : " + method.getJavaMember().getDeclaringClass().getName() + " @Qualifier : "
                                                                 + ann.annotationType().getName()
                                                                 + " must have @NonBinding valued members for its array-valued and annotation valued members");
                    }
                }
            }
        }
        else
        {
            Method[] methods = webBeansContext.getSecurityService().doPrivilegedGetDeclaredMethods(ann.annotationType());

            for (Method method : methods)
            {
                Class<?> clazz = method.getReturnType();
                if (clazz.isArray() || clazz.isAnnotation())
                {
                    if (!AnnotationUtil.hasAnnotation(method.getDeclaredAnnotations(), Nonbinding.class))
                    {
                        throw new WebBeansConfigurationException("@Qualifier : " + ann.annotationType().getName()
                                                             + " must have @NonBinding valued members for its array-valued and annotation valued members");
                    }
                }
            }
        }

        if (!isQualifierAnnotation(ann.annotationType()))
        {
            throw new IllegalArgumentException("Qualifier annotations must be annotated with @Qualifier");
        }
    }