Skip to content

Commit d5c5fb6

Browse files
committed
Merge pull request #50419 from codingkiddo
Closes gh-50419 * pr/50419: Polish code to use instanceof pattern matching in conditions
2 parents c66ea41 + 8dfdb24 commit d5c5fb6

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionEvaluationReport.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ public ConditionEvaluationReport getParent() {
165165
* @return the {@link ConditionEvaluationReport} or {@code null}
166166
*/
167167
public static ConditionEvaluationReport find(BeanFactory beanFactory) {
168-
if (beanFactory instanceof ConfigurableListableBeanFactory) {
169-
return ConditionEvaluationReport.get((ConfigurableListableBeanFactory) beanFactory);
168+
if (beanFactory instanceof ConfigurableListableBeanFactory configurableListableBeanFactory) {
169+
return ConditionEvaluationReport.get(configurableListableBeanFactory);
170170
}
171171
return null;
172172
}

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,8 +659,8 @@ protected final String getAnnotationName() {
659659
}
660660

661661
private Set<BeanType> deducedBeanType(ConditionContext context, AnnotatedTypeMetadata metadata) {
662-
if (metadata instanceof MethodMetadata && metadata.isAnnotated(Bean.class.getName())) {
663-
return deducedBeanTypeForBeanMethod(context, (MethodMetadata) metadata);
662+
if (metadata instanceof MethodMetadata methodMetadata && metadata.isAnnotated(Bean.class.getName())) {
663+
return deducedBeanTypeForBeanMethod(context, methodMetadata);
664664
}
665665
return Collections.emptySet();
666666
}

0 commit comments

Comments
 (0)