From 06265ee617dbbfa3e3ebe2cec7233258bc3644f4 Mon Sep 17 00:00:00 2001 From: Tobias Lippert Date: Sun, 21 Jan 2024 18:47:43 +0100 Subject: [PATCH] Use pattern variables See gh-39259 --- .../bom/bomr/version/ReleaseTrainDependencyVersion.java | 6 ++---- .../properties/migrator/PropertiesMigrationReporter.java | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/version/ReleaseTrainDependencyVersion.java b/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/version/ReleaseTrainDependencyVersion.java index 12328ee323..fc999a2526 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/version/ReleaseTrainDependencyVersion.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/version/ReleaseTrainDependencyVersion.java @@ -64,10 +64,9 @@ final class ReleaseTrainDependencyVersion implements DependencyVersion { @Override public boolean isUpgrade(DependencyVersion candidate, boolean movingToSnapshots) { - if (!(candidate instanceof ReleaseTrainDependencyVersion)) { + if (!(candidate instanceof ReleaseTrainDependencyVersion candidateReleaseTrain)) { return true; } - ReleaseTrainDependencyVersion candidateReleaseTrain = (ReleaseTrainDependencyVersion) candidate; int comparison = this.releaseTrain.compareTo(candidateReleaseTrain.releaseTrain); if (comparison != 0) { return comparison < 0; @@ -88,10 +87,9 @@ final class ReleaseTrainDependencyVersion implements DependencyVersion { @Override public boolean isSnapshotFor(DependencyVersion candidate) { - if (!isSnapshot() || !(candidate instanceof ReleaseTrainDependencyVersion)) { + if (!isSnapshot() || !(candidate instanceof ReleaseTrainDependencyVersion candidateReleaseTrain)) { return false; } - ReleaseTrainDependencyVersion candidateReleaseTrain = (ReleaseTrainDependencyVersion) candidate; return this.releaseTrain.equals(candidateReleaseTrain.releaseTrain); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReporter.java b/spring-boot-project/spring-boot-tools/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReporter.java index 85603a7bb0..9872c6ecd3 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReporter.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReporter.java @@ -127,8 +127,7 @@ class PropertiesMigrationReporter { new PropertyMigration(match, metadata, determineReplacementMetadata(metadata), false)); } // Prefix match for maps - if (isMapType(metadata) && propertySource instanceof IterableConfigurationPropertySource) { - IterableConfigurationPropertySource iterableSource = (IterableConfigurationPropertySource) propertySource; + if (isMapType(metadata) && propertySource instanceof IterableConfigurationPropertySource iterableSource) { iterableSource.stream() .filter(metadataName::isAncestorOf) .map(propertySource::getConfigurationProperty)