public abstract class BeanFactoryAnnotationUtils
extends java.lang.Object
@Qualifier annotation.BeanFactoryUtils| Constructor and Description |
|---|
BeanFactoryAnnotationUtils() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
isQualifierMatch(java.util.function.Predicate<java.lang.String> qualifier,
java.lang.String beanName,
BeanFactory beanFactory)
Check whether the named bean declares a qualifier of the given name.
|
static <T> T |
qualifiedBeanOfType(BeanFactory beanFactory,
java.lang.Class<T> beanType,
java.lang.String qualifier)
Obtain a bean of type
T from the given BeanFactory declaring a
qualifier (e.g. |
public static <T> T qualifiedBeanOfType(BeanFactory beanFactory, java.lang.Class<T> beanType, java.lang.String qualifier) throws BeansException
T from the given BeanFactory declaring a
qualifier (e.g. via <qualifier> or @Qualifier) matching the given
qualifier, or having a bean name matching the given qualifier.beanFactory - the BeanFactory to get the target bean frombeanType - the type of bean to retrievequalifier - the qualifier for selecting between multiple bean matchesT (never null)NoUniqueBeanDefinitionException - if multiple matching beans of type T foundNoSuchBeanDefinitionException - if no matching bean of type T foundBeansException - if the bean could not be createdBeanFactory.getBean(Class)public static boolean isQualifierMatch(java.util.function.Predicate<java.lang.String> qualifier,
java.lang.String beanName,
@Nullable
BeanFactory beanFactory)
qualifier - the qualifier to matchbeanName - the name of the candidate beanbeanFactory - the BeanFactory from which to retrieve the named beantrue if either the bean definition (in the XML case)
or the bean's factory method (in the @Bean case) defines a matching
qualifier value (through <qualifier> or @Qualifier)