Replace Collections.sort() with direct sort call
Replace existing `Collections.sort(...)` calls with `.sort(...)` directly on the collection instance. See gh-9781
This commit is contained in:
parent
04fdec6f8b
commit
4a189bdee7
|
@ -199,7 +199,7 @@ public class EndpointDocumentation {
|
|||
private Collection<? extends MvcEndpoint> getEndpoints() {
|
||||
List<? extends MvcEndpoint> endpoints = new ArrayList<>(
|
||||
this.mvcEndpoints.getEndpoints());
|
||||
Collections.sort(endpoints, new Comparator<MvcEndpoint>() {
|
||||
endpoints.sort(new Comparator<MvcEndpoint>() {
|
||||
@Override
|
||||
public int compare(MvcEndpoint o1, MvcEndpoint o2) {
|
||||
return o1.getPath().compareTo(o2.getPath());
|
||||
|
|
|
@ -149,7 +149,7 @@ public class EndpointAutoConfiguration {
|
|||
if (this.publicMetrics != null) {
|
||||
publicMetrics.addAll(this.publicMetrics);
|
||||
}
|
||||
Collections.sort(publicMetrics, AnnotationAwareOrderComparator.INSTANCE);
|
||||
publicMetrics.sort(AnnotationAwareOrderComparator.INSTANCE);
|
||||
return new MetricsEndpoint(publicMetrics);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ package org.springframework.boot.actuate.health;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -80,7 +79,7 @@ public class OrderedHealthAggregator extends AbstractHealthAggregator {
|
|||
return Status.UNKNOWN;
|
||||
}
|
||||
// Sort given Status instances by configured order
|
||||
Collections.sort(filteredCandidates, new StatusComparator(this.statusOrder));
|
||||
filteredCandidates.sort(new StatusComparator(this.statusOrder));
|
||||
return filteredCandidates.get(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ class AutoConfigurationSorter {
|
|||
// Initially sort alphabetically
|
||||
Collections.sort(orderedClassNames);
|
||||
// Then sort by order
|
||||
Collections.sort(orderedClassNames, new Comparator<String>() {
|
||||
orderedClassNames.sort(new Comparator<String>() {
|
||||
|
||||
@Override
|
||||
public int compare(String o1, String o2) {
|
||||
|
|
|
@ -94,9 +94,8 @@ class ServiceCapabilitiesReportGenerator {
|
|||
|
||||
private List<Dependency> getSortedDependencies(InitializrServiceMetadata metadata) {
|
||||
ArrayList<Dependency> dependencies = new ArrayList<>(metadata.getDependencies());
|
||||
Collections.sort(dependencies, new Comparator<Dependency>() {
|
||||
@Override
|
||||
public int compare(Dependency o1, Dependency o2) {
|
||||
dependencies.sort(new Comparator<Dependency>() {
|
||||
@Override public int compare(Dependency o1, Dependency o2) {
|
||||
return o1.getId().compareTo(o2.getId());
|
||||
}
|
||||
});
|
||||
|
|
|
@ -124,7 +124,7 @@ public class GroovyCompiler {
|
|||
.load(SpringBootAstTransformation.class)) {
|
||||
this.transformations.add(transformation);
|
||||
}
|
||||
Collections.sort(this.transformations, AnnotationAwareOrderComparator.INSTANCE);
|
||||
this.transformations.sort(AnnotationAwareOrderComparator.INSTANCE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -234,7 +234,7 @@ public abstract class MainClassFinder {
|
|||
static <T> T doWithMainClasses(JarFile jarFile, String classesLocation,
|
||||
MainClassCallback<T> callback) throws IOException {
|
||||
List<JarEntry> classEntries = getClassEntries(jarFile, classesLocation);
|
||||
Collections.sort(classEntries, new ClassEntryComparator());
|
||||
classEntries.sort(new ClassEntryComparator());
|
||||
for (JarEntry entry : classEntries) {
|
||||
try (InputStream inputStream = new BufferedInputStream(
|
||||
jarFile.getInputStream(entry))) {
|
||||
|
|
|
@ -1309,7 +1309,7 @@ public class SpringApplication {
|
|||
private static <E> Set<E> asUnmodifiableOrderedSet(Collection<E> elements) {
|
||||
List<E> list = new ArrayList<>();
|
||||
list.addAll(elements);
|
||||
Collections.sort(list, AnnotationAwareOrderComparator.INSTANCE);
|
||||
list.sort(AnnotationAwareOrderComparator.INSTANCE);
|
||||
return new LinkedHashSet<>(list);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
package org.springframework.boot.context.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
@ -110,7 +109,7 @@ public class DelegatingApplicationContextInitializer implements
|
|||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
private void applyInitializers(ConfigurableApplicationContext context,
|
||||
List<ApplicationContextInitializer<?>> initializers) {
|
||||
Collections.sort(initializers, new AnnotationAwareOrderComparator());
|
||||
initializers.sort(new AnnotationAwareOrderComparator());
|
||||
for (ApplicationContextInitializer initializer : initializers) {
|
||||
initializer.initialize(context);
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ public class JavaLoggingSystem extends AbstractLoggingSystem {
|
|||
while (names.hasMoreElements()) {
|
||||
result.add(getLoggerConfiguration(names.nextElement()));
|
||||
}
|
||||
Collections.sort(result, CONFIGURATION_COMPARATOR);
|
||||
result.sort(CONFIGURATION_COMPARATOR);
|
||||
return Collections.unmodifiableList(result);
|
||||
}
|
||||
|
||||
|
|
|
@ -220,7 +220,7 @@ public class Log4J2LoggingSystem extends Slf4JLoggingSystem {
|
|||
for (LoggerConfig loggerConfig : configuration.getLoggers().values()) {
|
||||
result.add(convertLoggerConfiguration(loggerConfig));
|
||||
}
|
||||
Collections.sort(result, CONFIGURATION_COMPARATOR);
|
||||
result.sort(CONFIGURATION_COMPARATOR);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ import java.net.URL;
|
|||
import java.security.CodeSource;
|
||||
import java.security.ProtectionDomain;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -213,7 +212,7 @@ public class LogbackLoggingSystem extends Slf4JLoggingSystem {
|
|||
for (ch.qos.logback.classic.Logger logger : getLoggerContext().getLoggerList()) {
|
||||
result.add(getLoggerConfiguration(logger));
|
||||
}
|
||||
Collections.sort(result, CONFIGURATION_COMPARATOR);
|
||||
result.sort(CONFIGURATION_COMPARATOR);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ public class ErrorPageRegistrarBeanPostProcessor
|
|||
// Look up does not include the parent context
|
||||
this.registrars = new ArrayList<>(this.beanFactory
|
||||
.getBeansOfType(ErrorPageRegistrar.class, false, false).values());
|
||||
Collections.sort(this.registrars, AnnotationAwareOrderComparator.INSTANCE);
|
||||
this.registrars.sort(AnnotationAwareOrderComparator.INSTANCE);
|
||||
this.registrars = Collections.unmodifiableList(this.registrars);
|
||||
}
|
||||
return this.registrars;
|
||||
|
|
|
@ -114,7 +114,7 @@ public class WebServerFactoryCustomizerBeanPostProcessor
|
|||
if (this.customizers == null) {
|
||||
// Look up does not include the parent context
|
||||
this.customizers = new ArrayList<>(getWebServerFactoryCustomizerBeans());
|
||||
Collections.sort(this.customizers, AnnotationAwareOrderComparator.INSTANCE);
|
||||
this.customizers.sort(AnnotationAwareOrderComparator.INSTANCE);
|
||||
this.customizers = Collections.unmodifiableList(this.customizers);
|
||||
}
|
||||
return this.customizers;
|
||||
|
|
|
@ -238,7 +238,7 @@ public class ServletContextInitializerBeans
|
|||
}
|
||||
}
|
||||
beans.addAll(map.entrySet());
|
||||
Collections.sort(beans, comparator);
|
||||
beans.sort(comparator);
|
||||
return beans;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue