Use Comparator.comparing

See gh-33987
This commit is contained in:
Krzysztof Krason
2023-01-26 18:31:17 -08:00
committed by Phillip Webb
parent d3efd7e091
commit 55a50d565c
2 changed files with 7 additions and 5 deletions

View File

@@ -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<Descriptor> 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)));