Use Stream.toList()

See gh-36167
This commit is contained in:
Johnny Lim
2023-07-03 12:00:18 +09:00
committed by Andy Wilkinson
parent bdead8d0e3
commit 0fa58c04e7
8 changed files with 13 additions and 22 deletions

View File

@@ -84,10 +84,10 @@ class ResolvedDependencies {
}
void resolvedArtifacts(Provider<Set<ResolvedArtifactResult>> resolvedArtifacts) {
this.artifactFiles.addAll(resolvedArtifacts
.map((artifacts) -> artifacts.stream().map(ResolvedArtifactResult::getFile).collect(Collectors.toList())));
this.artifactIds.addAll(resolvedArtifacts
.map((artifacts) -> artifacts.stream().map(ResolvedArtifactResult::getId).collect(Collectors.toList())));
this.artifactFiles.addAll(
resolvedArtifacts.map((artifacts) -> artifacts.stream().map(ResolvedArtifactResult::getFile).toList()));
this.artifactIds.addAll(
resolvedArtifacts.map((artifacts) -> artifacts.stream().map(ResolvedArtifactResult::getId).toList()));
}
DependencyDescriptor find(File file) {

View File

@@ -23,7 +23,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import org.springframework.boot.configurationmetadata.ConfigurationMetadataProperty;
import org.springframework.boot.configurationmetadata.ConfigurationMetadataRepository;
@@ -82,9 +81,7 @@ class PropertiesMigrationReporter {
private PropertySource<?> mapPropertiesWithReplacement(PropertiesMigrationReport report, String name,
List<PropertyMigration> properties) {
report.add(name, properties);
List<PropertyMigration> renamed = properties.stream()
.filter(PropertyMigration::isCompatibleType)
.collect(Collectors.toList());
List<PropertyMigration> renamed = properties.stream().filter(PropertyMigration::isCompatibleType).toList();
if (renamed.isEmpty()) {
return null;
}
@@ -118,10 +115,7 @@ class PropertiesMigrationReporter {
private Map<String, List<PropertyMigration>> getMatchingProperties(
Predicate<ConfigurationMetadataProperty> filter) {
MultiValueMap<String, PropertyMigration> result = new LinkedMultiValueMap<>();
List<ConfigurationMetadataProperty> candidates = this.allProperties.values()
.stream()
.filter(filter)
.collect(Collectors.toList());
List<ConfigurationMetadataProperty> candidates = this.allProperties.values().stream().filter(filter).toList();
getPropertySourcesAsMap().forEach((propertySourceName, propertySource) -> candidates.forEach((metadata) -> {
ConfigurationPropertyName metadataName = ConfigurationPropertyName.isValid(metadata.getId())
? ConfigurationPropertyName.of(metadata.getId())

View File

@@ -33,7 +33,6 @@ import java.util.Set;
import java.util.jar.Attributes;
import java.util.jar.JarFile;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
@@ -97,7 +96,7 @@ final class ModifiedClassPathClassLoader extends URLClassLoader {
candidates.addAll(getAnnotatedElements(arguments.toArray()));
List<AnnotatedElement> annotatedElements = candidates.stream()
.filter(ModifiedClassPathClassLoader::hasAnnotation)
.collect(Collectors.toList());
.toList();
if (annotatedElements.isEmpty()) {
return null;
}