Skip to content

Commit 55a50d5

Browse files
krzykphilwebb
authored andcommitted
Use Comparator.comparing
See gh-33987
1 parent d3efd7e commit 55a50d5

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

buildSrc/src/main/java/org/springframework/boot/build/testing/TestResultsOverview.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2023 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.
@@ -16,10 +16,12 @@
1616

1717
package org.springframework.boot.build.testing;
1818

19+
import java.util.Comparator;
1920
import java.util.List;
2021
import java.util.Map;
2122
import java.util.TreeMap;
2223

24+
import org.gradle.api.DefaultTask;
2325
import org.gradle.api.services.BuildService;
2426
import org.gradle.api.services.BuildServiceParameters;
2527
import org.gradle.api.tasks.testing.Test;
@@ -35,8 +37,7 @@
3537
public abstract class TestResultsOverview
3638
implements BuildService<BuildServiceParameters.None>, OperationCompletionListener, AutoCloseable {
3739

38-
private final Map<Test, List<TestFailure>> testFailures = new TreeMap<>(
39-
(one, two) -> one.getPath().compareTo(two.getPath()));
40+
private final Map<Test, List<TestFailure>> testFailures = new TreeMap<>(Comparator.comparing(DefaultTask::getPath));
4041

4142
private final Object monitor = new Object();
4243

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/MutuallyExclusiveConfigurationPropertiesFailureAnalyzer.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2023 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.
@@ -18,6 +18,7 @@
1818

1919
import java.util.ArrayList;
2020
import java.util.Collection;
21+
import java.util.Comparator;
2122
import java.util.List;
2223
import java.util.Set;
2324
import java.util.TreeSet;
@@ -83,7 +84,7 @@ private Stream<PropertySource<?>> getPropertySources() {
8384

8485
private void appendDetails(StringBuilder message, MutuallyExclusiveConfigurationPropertiesException cause,
8586
List<Descriptor> descriptors) {
86-
descriptors.sort((d1, d2) -> d1.propertyName.compareTo(d2.propertyName));
87+
descriptors.sort(Comparator.comparing((descriptor) -> descriptor.propertyName));
8788
message.append(String.format("The following configuration properties are mutually exclusive:%n%n"));
8889
sortedStrings(cause.getMutuallyExclusiveNames())
8990
.forEach((name) -> message.append(String.format("\t%s%n", name)));

0 commit comments

Comments
 (0)