public void checkSpecialization() {
        if (isSpecializing()) {
            boolean isNameDefined = getAnnotated().isAnnotationPresent(Named.class);
            String previousSpecializedBeanName = null;
            for (AbstractBean<?, ?> specializedBean : getSpecializedBeans()) {
                String name = specializedBean.getName();
                if (previousSpecializedBeanName != null && name != null && !previousSpecializedBeanName.equals(specializedBean.getName())) {
                    // there may be multiple beans specialized by this bean - make sure they all share the same name
                    throw BeanLogger.LOG.beansWithDifferentBeanNamesCannotBeSpecialized(previousSpecializedBeanName, specializedBean.getName(), this);
                }
                previousSpecializedBeanName = name;
                if (isNameDefined && name != null) {
                    throw BeanLogger.LOG.nameNotAllowedOnSpecialization(getAnnotated(), specializedBean.getAnnotated());
                }

                // When a specializing bean extends the raw type of a generic superclass, types of the generic superclass are
                // added into types of the specializing bean because of assignability rules. However, ParameterizedTypes among
                // these types are NOT types of the specializing bean (that's the way java works)
                boolean rawInsteadOfGeneric = (this instanceof AbstractClassBean<?>
                        && specializedBean.getBeanClass().getTypeParameters().length > 0
                        && !(((AbstractClassBean<?>) this).getBeanClass().getGenericSuperclass() instanceof ParameterizedType));
                for (Type specializedType : specializedBean.getTypes()) {
                    if (rawInsteadOfGeneric && specializedType instanceof ParameterizedType) {
                        throw BeanLogger.LOG.specializingBeanMissingSpecializedType(this, specializedType, specializedBean);
                    }
                    boolean contains = getTypes().contains(specializedType);
                    if (!contains) {
                        for (Type specializingType : getTypes()) {
                            // In case 'type' is a ParameterizedType, two bean types equivalent in the CDI sense may not be
                            // equal in the java sense. Therefore we have to use our own equality util.
                            if (TypeEqualitySpecializationUtils.areTheSame(specializingType, specializedType)) {
                                contains = true;
                                break;
                            }
                        }
                    }
                    if (!contains) {
                        throw BeanLogger.LOG.specializingBeanMissingSpecializedType(this, specializedType, specializedBean);
                    }
                }
            }
        }
    }
public void checkSpecialization ( ) { if ( isSpecializing ( ) ) { boolean isNameDefined = getAnnotated ( ) . isAnnotationPresent ( Named . class ) ; String previousSpecializedBeanName = null ; for ( AbstractBean < ? , ? > specializedBean : getSpecializedBeans ( ) ) { String name = specializedBean . getName ( ) ; if ( previousSpecializedBeanName != null && name != null && ! previousSpecializedBeanName . equals ( specializedBean . getName ( ) ) ) { throw BeanLogger . LOG . beansWithDifferentBeanNamesCannotBeSpecialized ( previousSpecializedBeanName , specializedBean . getName ( ) , this ) ; } previousSpecializedBeanName = name ; if ( isNameDefined && name != null ) { throw BeanLogger . LOG . nameNotAllowedOnSpecialization ( getAnnotated ( ) , specializedBean . getAnnotated ( ) ) ; } boolean rawInsteadOfGeneric = ( this instanceof AbstractClassBean < ? > && specializedBean . getBeanClass ( ) . getTypeParameters ( ) . length > 0 && ! ( ( ( AbstractClassBean < ? > ) this ) . getBeanClass ( ) . getGenericSuperclass ( ) instanceof ParameterizedType ) ) ; for ( Type specializedType : specializedBean . getTypes ( ) ) { if ( rawInsteadOfGeneric && specializedType instanceof ParameterizedType ) { throw BeanLogger . LOG . specializingBeanMissingSpecializedType ( this , specializedType , specializedBean ) ; } boolean contains = getTypes ( ) . contains ( specializedType ) ; if ( ! contains ) { for ( Type specializingType : getTypes ( ) ) { if ( TypeEqualitySpecializationUtils . areTheSame ( specializingType , specializedType ) ) { contains = true ; break ; } } } if ( ! contains ) { throw BeanLogger . LOG . specializingBeanMissingSpecializedType ( this , specializedType , specializedBean ) ; } } } } }
Validates specialization if this bean specializes another bean.