mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Better use of key iterator
This commit uses an EntrySet instead of looping over the keys and retrieving the value in a separate call. Issue: SPR-12356
This commit is contained in:
committed by
Stephane Nicoll
parent
66069333f1
commit
2e5d752e15
+3
-2
@@ -79,13 +79,14 @@ public class BeanFactoryAnnotationUtils {
|
||||
private static <T> T qualifiedBeanOfType(ConfigurableListableBeanFactory bf, Class<T> beanType, String qualifier) {
|
||||
Map<String, T> candidateBeans = BeanFactoryUtils.beansOfTypeIncludingAncestors(bf, beanType);
|
||||
T matchingBean = null;
|
||||
for (String beanName : candidateBeans.keySet()) {
|
||||
for (Map.Entry<String, T> entry : candidateBeans.entrySet()) {
|
||||
String beanName = entry.getKey();
|
||||
if (isQualifierMatch(qualifier, beanName, bf)) {
|
||||
if (matchingBean != null) {
|
||||
throw new NoSuchBeanDefinitionException(qualifier, "No unique " + beanType.getSimpleName() +
|
||||
" bean found for qualifier '" + qualifier + "'");
|
||||
}
|
||||
matchingBean = candidateBeans.get(beanName);
|
||||
matchingBean = entry.getValue();
|
||||
}
|
||||
}
|
||||
if (matchingBean != null) {
|
||||
|
||||
Reference in New Issue
Block a user