From 55a50d565cc5c8dbb4a4f0b91abd97760a807579 Mon Sep 17 00:00:00 2001 From: Krzysztof Krason Date: Thu, 26 Jan 2023 18:31:17 -0800 Subject: [PATCH] Use Comparator.comparing See gh-33987 --- .../boot/build/testing/TestResultsOverview.java | 7 ++++--- ...llyExclusiveConfigurationPropertiesFailureAnalyzer.java | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/buildSrc/src/main/java/org/springframework/boot/build/testing/TestResultsOverview.java b/buildSrc/src/main/java/org/springframework/boot/build/testing/TestResultsOverview.java index b656a6c3a09..6319024eda9 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/testing/TestResultsOverview.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/testing/TestResultsOverview.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2022 the original author or authors. + * Copyright 2012-2023 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. @@ -16,10 +16,12 @@ package org.springframework.boot.build.testing; +import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.TreeMap; +import org.gradle.api.DefaultTask; import org.gradle.api.services.BuildService; import org.gradle.api.services.BuildServiceParameters; import org.gradle.api.tasks.testing.Test; @@ -35,8 +37,7 @@ import org.gradle.tooling.events.OperationCompletionListener; public abstract class TestResultsOverview implements BuildService, OperationCompletionListener, AutoCloseable { - private final Map> testFailures = new TreeMap<>( - (one, two) -> one.getPath().compareTo(two.getPath())); + private final Map> testFailures = new TreeMap<>(Comparator.comparing(DefaultTask::getPath)); private final Object monitor = new Object(); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/MutuallyExclusiveConfigurationPropertiesFailureAnalyzer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/MutuallyExclusiveConfigurationPropertiesFailureAnalyzer.java index 24eb421b767..ab0d98414e9 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/MutuallyExclusiveConfigurationPropertiesFailureAnalyzer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/MutuallyExclusiveConfigurationPropertiesFailureAnalyzer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2022 the original author or authors. + * Copyright 2012-2023 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. @@ -18,6 +18,7 @@ package org.springframework.boot.diagnostics.analyzer; import java.util.ArrayList; import java.util.Collection; +import java.util.Comparator; import java.util.List; import java.util.Set; import java.util.TreeSet; @@ -83,7 +84,7 @@ class MutuallyExclusiveConfigurationPropertiesFailureAnalyzer private void appendDetails(StringBuilder message, MutuallyExclusiveConfigurationPropertiesException cause, List descriptors) { - descriptors.sort((d1, d2) -> d1.propertyName.compareTo(d2.propertyName)); + descriptors.sort(Comparator.comparing((descriptor) -> descriptor.propertyName)); message.append(String.format("The following configuration properties are mutually exclusive:%n%n")); sortedStrings(cause.getMutuallyExclusiveNames()) .forEach((name) -> message.append(String.format("\t%s%n", name)));