evaluateConditionalOnSingleCandidate() — spring-boot Function Reference
Architecture documentation for the evaluateConditionalOnSingleCandidate() function in OnBeanCondition.java from the spring-boot codebase.
Entity Profile
Dependency Diagram
graph TD fd603d49_4269_fbde_174b_b296c20d4b2d["evaluateConditionalOnSingleCandidate()"] 43c9ea98_9071_6b63_b2a4_18a4917b5b73["getMatchOutcome()"] 43c9ea98_9071_6b63_b2a4_18a4917b5b73 -->|calls| fd603d49_4269_fbde_174b_b296c20d4b2d e8d44fa6_45ad_6d14_6468_53ed18c907e0["getMatchingBeans()"] fd603d49_4269_fbde_174b_b296c20d4b2d -->|calls| e8d44fa6_45ad_6d14_6468_53ed18c907e0 bed53d29_b802_2b28_6cb2_c1f8993e9c48["isAllMatched()"] fd603d49_4269_fbde_174b_b296c20d4b2d -->|calls| bed53d29_b802_2b28_6cb2_c1f8993e9c48 18f5fe99_be23_a43e_a6e4_fe16d6894135["message()"] fd603d49_4269_fbde_174b_b296c20d4b2d -->|calls| 18f5fe99_be23_a43e_a6e4_fe16d6894135 d4435eba_5621_88a1_37f8_edee25c820a2["getNamesOfAllMatches()"] fd603d49_4269_fbde_174b_b296c20d4b2d -->|calls| d4435eba_5621_88a1_37f8_edee25c820a2 4929f590_1d30_916c_b90d_61b942e14e01["getBeanDefinitions()"] fd603d49_4269_fbde_174b_b296c20d4b2d -->|calls| 4929f590_1d30_916c_b90d_61b942e14e01 1ac703ed_372f_03eb_304a_f76d7a096ee5["getStrategy()"] fd603d49_4269_fbde_174b_b296c20d4b2d -->|calls| 1ac703ed_372f_03eb_304a_f76d7a096ee5 17f95dc1_d315_25e2_bf40_feeb29f31dfa["getPrimaryBeans()"] fd603d49_4269_fbde_174b_b296c20d4b2d -->|calls| 17f95dc1_d315_25e2_bf40_feeb29f31dfa c0607bbd_e1af_01e3_85d4_a6fb09a3e424["getNonFallbackBeans()"] fd603d49_4269_fbde_174b_b296c20d4b2d -->|calls| c0607bbd_e1af_01e3_85d4_a6fb09a3e424 style fd603d49_4269_fbde_174b_b296c20d4b2d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
core/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java lines 168–200
private ConditionOutcome evaluateConditionalOnSingleCandidate(Spec<ConditionalOnSingleCandidate> spec,
ConditionMessage matchMessage) {
MatchResult matchResult = getMatchingBeans(spec);
if (!matchResult.isAllMatched()) {
return ConditionOutcome.noMatch(spec.message().didNotFind("any beans").atAll());
}
Set<String> allBeans = matchResult.getNamesOfAllMatches();
if (allBeans.size() == 1) {
return ConditionOutcome
.match(spec.message(matchMessage).found("a single bean").items(Style.QUOTE, allBeans));
}
ConfigurableListableBeanFactory beanFactory = spec.context.getBeanFactory();
Assert.state(beanFactory != null, "'beanFactory' must not be null");
Map<String, @Nullable BeanDefinition> beanDefinitions = getBeanDefinitions(beanFactory, allBeans,
spec.getStrategy() == SearchStrategy.ALL);
List<String> primaryBeans = getPrimaryBeans(beanDefinitions);
if (primaryBeans.size() == 1) {
return ConditionOutcome.match(spec.message(matchMessage)
.found("a single primary bean '" + primaryBeans.get(0) + "' from beans")
.items(Style.QUOTE, allBeans));
}
if (primaryBeans.size() > 1) {
return ConditionOutcome
.noMatch(spec.message().found("multiple primary beans").items(Style.QUOTE, primaryBeans));
}
List<String> nonFallbackBeans = getNonFallbackBeans(beanDefinitions);
if (nonFallbackBeans.size() == 1) {
return ConditionOutcome.match(spec.message(matchMessage)
.found("a single non-fallback bean '" + nonFallbackBeans.get(0) + "' from beans")
.items(Style.QUOTE, allBeans));
}
return ConditionOutcome.noMatch(spec.message().found("multiple beans").items(Style.QUOTE, allBeans));
}
Domain
Subdomains
Calls
- getBeanDefinitions()
- getMatchingBeans()
- getNamesOfAllMatches()
- getNonFallbackBeans()
- getPrimaryBeans()
- getStrategy()
- isAllMatched()
- message()
Called By
Source
Frequently Asked Questions
What does evaluateConditionalOnSingleCandidate() do?
evaluateConditionalOnSingleCandidate() is a function in the spring-boot codebase.
What does evaluateConditionalOnSingleCandidate() call?
evaluateConditionalOnSingleCandidate() calls 8 function(s): getBeanDefinitions, getMatchingBeans, getNamesOfAllMatches, getNonFallbackBeans, getPrimaryBeans, getStrategy, isAllMatched, message.
What calls evaluateConditionalOnSingleCandidate()?
evaluateConditionalOnSingleCandidate() is called by 1 function(s): getMatchOutcome.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free