Skip to content

Commit 6efc3da

Browse files
committed
Apply "instance pattern matching"
1 parent 07ba13c commit 6efc3da

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

spring-webmvc/src/main/java/org/springframework/web/servlet/view/ViewResolverComposite.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -78,26 +78,26 @@ public int getOrder() {
7878
@Override
7979
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
8080
for (ViewResolver viewResolver : this.viewResolvers) {
81-
if (viewResolver instanceof ApplicationContextAware) {
82-
((ApplicationContextAware)viewResolver).setApplicationContext(applicationContext);
81+
if (viewResolver instanceof ApplicationContextAware applicationContextAware) {
82+
applicationContextAware.setApplicationContext(applicationContext);
8383
}
8484
}
8585
}
8686

8787
@Override
8888
public void setServletContext(ServletContext servletContext) {
8989
for (ViewResolver viewResolver : this.viewResolvers) {
90-
if (viewResolver instanceof ServletContextAware) {
91-
((ServletContextAware)viewResolver).setServletContext(servletContext);
90+
if (viewResolver instanceof ServletContextAware servletContextAware) {
91+
servletContextAware.setServletContext(servletContext);
9292
}
9393
}
9494
}
9595

9696
@Override
9797
public void afterPropertiesSet() throws Exception {
9898
for (ViewResolver viewResolver : this.viewResolvers) {
99-
if (viewResolver instanceof InitializingBean) {
100-
((InitializingBean) viewResolver).afterPropertiesSet();
99+
if (viewResolver instanceof InitializingBean initializingBean) {
100+
initializingBean.afterPropertiesSet();
101101
}
102102
}
103103
}

0 commit comments

Comments
 (0)