Use pattern matching for instanceof where appropriate
See gh-31475
This commit is contained in:
committed by
Andy Wilkinson
parent
a7b98e7312
commit
5db04da275
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 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.
|
||||
@@ -184,8 +184,8 @@ public class CliTester implements BeforeEachCallback, AfterEachCallback {
|
||||
@Override
|
||||
public void afterEach(ExtensionContext extensionContext) {
|
||||
for (AbstractCommand command : this.commands) {
|
||||
if (command != null && command instanceof RunCommand) {
|
||||
((RunCommand) command).stop();
|
||||
if (command instanceof RunCommand runCommand) {
|
||||
runCommand.stop();
|
||||
}
|
||||
}
|
||||
System.clearProperty("disableSpringSnapshotRepos");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 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.
|
||||
@@ -91,9 +91,9 @@ final class GenericBomAstTransformationTests {
|
||||
|
||||
private List<String> getValue() {
|
||||
Expression expression = findAnnotation().getMember("value");
|
||||
if (expression instanceof ListExpression) {
|
||||
if (expression instanceof ListExpression listExpression) {
|
||||
List<String> list = new ArrayList<>();
|
||||
for (Expression ex : ((ListExpression) expression).getExpressions()) {
|
||||
for (Expression ex : listExpression.getExpressions()) {
|
||||
list.add((String) ((ConstantExpression) ex).getValue());
|
||||
}
|
||||
return list;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 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.
|
||||
@@ -225,8 +225,8 @@ final class ResolveDependencyCoordinatesTransformationTests {
|
||||
|
||||
private Object getGrabAnnotationMemberAsString(String memberName) {
|
||||
Expression expression = this.grabAnnotation.getMember(memberName);
|
||||
if (expression instanceof ConstantExpression) {
|
||||
return ((ConstantExpression) expression).getValue();
|
||||
if (expression instanceof ConstantExpression constantExpression) {
|
||||
return constantExpression.getValue();
|
||||
}
|
||||
else if (expression == null) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user