Apply "instanceof pattern matching" in additional core classes
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -223,8 +223,8 @@ class ConfigurationClassBeanDefinitionReader {
|
||||
|
||||
if (metadata.isStatic()) {
|
||||
// static @Bean method
|
||||
if (configClass.getMetadata() instanceof StandardAnnotationMetadata) {
|
||||
beanDef.setBeanClass(((StandardAnnotationMetadata) configClass.getMetadata()).getIntrospectedClass());
|
||||
if (configClass.getMetadata() instanceof StandardAnnotationMetadata sam) {
|
||||
beanDef.setBeanClass(sam.getIntrospectedClass());
|
||||
}
|
||||
else {
|
||||
beanDef.setBeanClassName(configClass.getMetadata().getClassName());
|
||||
@@ -237,8 +237,8 @@ class ConfigurationClassBeanDefinitionReader {
|
||||
beanDef.setUniqueFactoryMethodName(methodName);
|
||||
}
|
||||
|
||||
if (metadata instanceof StandardMethodMetadata) {
|
||||
beanDef.setResolvedFactoryMethod(((StandardMethodMetadata) metadata).getIntrospectedMethod());
|
||||
if (metadata instanceof StandardMethodMetadata sam) {
|
||||
beanDef.setResolvedFactoryMethod(sam.getIntrospectedMethod());
|
||||
}
|
||||
|
||||
beanDef.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_CONSTRUCTOR);
|
||||
@@ -322,8 +322,8 @@ class ConfigurationClassBeanDefinitionReader {
|
||||
|
||||
// At this point, it's a top-level override (probably XML), just having been parsed
|
||||
// before configuration class processing kicks in...
|
||||
if (this.registry instanceof DefaultListableBeanFactory &&
|
||||
!((DefaultListableBeanFactory) this.registry).isAllowBeanDefinitionOverriding()) {
|
||||
if (this.registry instanceof DefaultListableBeanFactory dlbf &&
|
||||
!dlbf.isAllowBeanDefinitionOverriding()) {
|
||||
throw new BeanDefinitionStoreException(beanMethod.getConfigurationClass().getResource().getDescription(),
|
||||
beanName, "@Bean definition illegally overridden by existing bean definition: " + existingBeanDef);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user