Use pattern matching for instanceof where appropriate
Closes gh-28181
This commit is contained in:
committed by
Andy Wilkinson
parent
b17eb9d6b5
commit
f2101684b7
@@ -186,11 +186,10 @@ public class DevToolsDataSourceAutoConfiguration {
|
||||
return ConditionOutcome.noMatch(message.didNotFind("a single DataSourceProperties bean").atAll());
|
||||
}
|
||||
BeanDefinition dataSourceDefinition = context.getRegistry().getBeanDefinition(dataSourceBeanNames[0]);
|
||||
if (dataSourceDefinition instanceof AnnotatedBeanDefinition
|
||||
&& ((AnnotatedBeanDefinition) dataSourceDefinition).getFactoryMethodMetadata() != null
|
||||
&& ((AnnotatedBeanDefinition) dataSourceDefinition).getFactoryMethodMetadata()
|
||||
.getDeclaringClassName().startsWith(DataSourceAutoConfiguration.class.getPackage().getName()
|
||||
+ ".DataSourceConfiguration$")) {
|
||||
if (dataSourceDefinition instanceof AnnotatedBeanDefinition annotatedBeanDefinition
|
||||
&& annotatedBeanDefinition.getFactoryMethodMetadata() != null
|
||||
&& annotatedBeanDefinition.getFactoryMethodMetadata().getDeclaringClassName().startsWith(
|
||||
DataSourceAutoConfiguration.class.getPackage().getName() + ".DataSourceConfiguration$")) {
|
||||
return ConditionOutcome.match(message.foundExactly("auto-configured DataSource"));
|
||||
}
|
||||
return ConditionOutcome.noMatch(message.didNotFind("an auto-configured DataSource").atAll());
|
||||
|
||||
@@ -118,8 +118,8 @@ public class DevToolsR2dbcAutoConfiguration {
|
||||
return ConditionOutcome.noMatch(message.didNotFind("a single ConnectionFactory bean").atAll());
|
||||
}
|
||||
BeanDefinition beanDefinition = context.getRegistry().getBeanDefinition(beanNames[0]);
|
||||
if (beanDefinition instanceof AnnotatedBeanDefinition
|
||||
&& isAutoConfigured((AnnotatedBeanDefinition) beanDefinition)) {
|
||||
if (beanDefinition instanceof AnnotatedBeanDefinition annotatedBeanDefinition
|
||||
&& isAutoConfigured(annotatedBeanDefinition)) {
|
||||
return ConditionOutcome.match(message.foundExactly("auto-configured ConnectionFactory"));
|
||||
}
|
||||
return ConditionOutcome.noMatch(message.didNotFind("an auto-configured ConnectionFactory").atAll());
|
||||
|
||||
@@ -191,8 +191,8 @@ public class LocalDevToolsAutoConfiguration {
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ApplicationEvent event) {
|
||||
if (event instanceof ContextRefreshedEvent || (event instanceof ClassPathChangedEvent
|
||||
&& !((ClassPathChangedEvent) event).isRestartRequired())) {
|
||||
if (event instanceof ContextRefreshedEvent || (event instanceof ClassPathChangedEvent classPathChangedEvent
|
||||
&& !classPathChangedEvent.isRestartRequired())) {
|
||||
this.liveReloadServer.triggerReload();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user