public static BeanConfigurator read()

in deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/BeanConfiguratorUtils.java [39:99]


    public static <T> BeanConfigurator<T> read(BeanManager beanManager,
                                           BeanConfigurator<T> beanConfigurator,
                                           AnnotatedType<T> type)
    {
        // Weld doesnt support interfaces...
        if (!type.getJavaClass().isInterface())
        {
            return beanConfigurator.read(type);
        }

        boolean qualifierAdded = false;

        for (Annotation annotation : type.getAnnotations())
        {
            if (beanManager.isQualifier(annotation.annotationType()))
            {
                beanConfigurator.addQualifier(annotation);
                qualifierAdded = true;
            }
            else if (beanManager.isScope(annotation.annotationType()))
            {
                beanConfigurator.scope(annotation.annotationType());
            }
            else if (beanManager.isStereotype(annotation.annotationType()))
            {
                beanConfigurator.addStereotype(annotation.annotationType());
            }
            if (annotation instanceof Named)
            {
                String name = ((Named) annotation).value();
                if (name == null || name.isBlank())
                {
                    name = Introspector.decapitalize(type.getJavaClass().getSimpleName());
                }
                beanConfigurator.name(name);
            }
        }

        if (type.isAnnotationPresent(Typed.class))
        {
            Typed typed = type.getAnnotation(Typed.class);
            beanConfigurator.types(typed.value());
        }
        else
        {
            for (Class<?> c = type.getJavaClass(); c != Object.class && c != null; c = c.getSuperclass())
            {
                beanConfigurator.addTypes(c);
            }
            beanConfigurator.addTypes(type.getJavaClass().getInterfaces());
            beanConfigurator.addTypes(Object.class);
        }

        if (!qualifierAdded)
        {
            beanConfigurator.addQualifier(Default.Literal.INSTANCE);
        }
        beanConfigurator.addQualifier(Any.Literal.INSTANCE);

        return beanConfigurator;
    }