Skip to content

Commit e40f49d

Browse files
committed
Polish 'Use pattern variables'
See gh-39259
1 parent 06265ee commit e40f49d

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

buildSrc/src/main/java/org/springframework/boot/build/bom/bomr/version/ReleaseTrainDependencyVersion.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,25 @@ public int compareTo(DependencyVersion other) {
6464

6565
@Override
6666
public boolean isUpgrade(DependencyVersion candidate, boolean movingToSnapshots) {
67-
if (!(candidate instanceof ReleaseTrainDependencyVersion candidateReleaseTrain)) {
68-
return true;
67+
if (candidate instanceof ReleaseTrainDependencyVersion candidateReleaseTrain) {
68+
return isUpgrade(candidateReleaseTrain, movingToSnapshots);
6969
}
70-
int comparison = this.releaseTrain.compareTo(candidateReleaseTrain.releaseTrain);
70+
return true;
71+
}
72+
73+
private boolean isUpgrade(ReleaseTrainDependencyVersion candidate, boolean movingToSnapshots) {
74+
int comparison = this.releaseTrain.compareTo(candidate.releaseTrain);
7175
if (comparison != 0) {
7276
return comparison < 0;
7377
}
74-
if (movingToSnapshots && !isSnapshot() && candidateReleaseTrain.isSnapshot()) {
78+
if (movingToSnapshots && !isSnapshot() && candidate.isSnapshot()) {
7579
return true;
7680
}
77-
comparison = this.type.compareTo(candidateReleaseTrain.type);
81+
comparison = this.type.compareTo(candidate.type);
7882
if (comparison != 0) {
7983
return comparison < 0;
8084
}
81-
return Integer.compare(this.version, candidateReleaseTrain.version) < 0;
85+
return Integer.compare(this.version, candidate.version) < 0;
8286
}
8387

8488
private boolean isSnapshot() {

0 commit comments

Comments
 (0)