Use pattern matching for instanceof where appropriate
See gh-31475
This commit is contained in:
committed by
Andy Wilkinson
parent
a7b98e7312
commit
5db04da275
@@ -108,8 +108,8 @@ class CustomLayersProvider {
|
||||
NodeList children = element.getChildNodes();
|
||||
for (int i = 0; i < children.getLength(); i++) {
|
||||
Node child = children.item(i);
|
||||
if (child instanceof Element) {
|
||||
ContentSelector<T> selector = selectorFactory.apply((Element) child);
|
||||
if (child instanceof Element childElement) {
|
||||
ContentSelector<T> selector = selectorFactory.apply(childElement);
|
||||
selectors.add(selector);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-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.
|
||||
@@ -59,8 +59,7 @@ class JavaCompilerPluginConfiguration {
|
||||
Plugin plugin = this.project.getPlugin("org.apache.maven.plugins:maven-compiler-plugin");
|
||||
if (plugin != null) {
|
||||
Object pluginConfiguration = plugin.getConfiguration();
|
||||
if (pluginConfiguration instanceof Xpp3Dom) {
|
||||
Xpp3Dom dom = (Xpp3Dom) pluginConfiguration;
|
||||
if (pluginConfiguration instanceof Xpp3Dom dom) {
|
||||
return getNodeValue(dom, propertyName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-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.
|
||||
@@ -48,8 +48,8 @@ final class VersionExtractor {
|
||||
URL codeSourceLocation = cls.getProtectionDomain().getCodeSource().getLocation();
|
||||
try {
|
||||
URLConnection connection = codeSourceLocation.openConnection();
|
||||
if (connection instanceof JarURLConnection) {
|
||||
return getImplementationVersion(((JarURLConnection) connection).getJarFile());
|
||||
if (connection instanceof JarURLConnection jarURLConnection) {
|
||||
return getImplementationVersion(jarURLConnection.getJarFile());
|
||||
}
|
||||
try (JarFile jarFile = new JarFile(new File(codeSourceLocation.toURI()))) {
|
||||
return getImplementationVersion(jarFile);
|
||||
|
||||
Reference in New Issue
Block a user