Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Stream#toList() instead of collect() #311

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ public Collection<Path> generate(JteConfig config, Set<TemplateDescription> temp
new ModelGenerator(engine, "statictemplates", "StaticTemplates", "Templates", language),
new ModelGenerator(engine, "dynamictemplates", "DynamicTemplates", "Templates", language)
).map(g -> g.generate(config, templateDescriptionsFiltered, modelConfig))
.collect(Collectors.toList());
.toList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.Map;
import java.util.Optional;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import static gg.jte.extension.api.mocks.MockConfig.mockConfig;
import static gg.jte.extension.api.mocks.MockParamDescription.mockParamDescription;
Expand Down Expand Up @@ -188,7 +187,7 @@ public void generatesKotlinFacadesWhenParamHasDefaultValue() {
DYNAMIC_SOURCE_FILE.matcher(path.toString()).find() ||
STATIC_SOURCE_FILE.matcher(path.toString()).find()
)
.collect(Collectors.toList());
.toList();

assertThat(implementationsPaths).isNotEmpty();
implementationsPaths.forEach(path -> {
Expand Down
6 changes: 3 additions & 3 deletions jte/src/main/java/gg/jte/compiler/TemplateCompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void cleanAll() {
@Override
public List<String> generateAll() {
LinkedHashSet<ClassDefinition> classDefinitions = generate(codeResolver.resolveAllTemplateNames(), false);
return classDefinitions.stream().map(ClassDefinition::getSourceFileName).collect(Collectors.toList());
return classDefinitions.stream().map(ClassDefinition::getSourceFileName).toList();
}

@Override
Expand Down Expand Up @@ -127,7 +127,7 @@ private List<String> precompileClasses(LinkedHashSet<ClassDefinition> classDefin
javaCompiler.compile(javaFiles, javaCompilerClassPath, config, classDirectory, templateByClassName);
}

return classDefinitions.stream().map(ClassDefinition::getSourceFileName).collect(Collectors.toList());
return classDefinitions.stream().map(ClassDefinition::getSourceFileName).toList();
}

private List<String> getClassPath() {
Expand Down Expand Up @@ -205,7 +205,7 @@ private LinkedHashSet<ClassDefinition> generate(List<String> names, boolean trac

List<JteExtension> generatorExtensions = config.extensionClasses.entrySet().stream()
.map(this::loadExtension)
.collect(Collectors.toList());
.toList();
if (DEBUG) {
System.out.printf("extensionClasses=%s generatorExtensions=%s%n", config.extensionClasses, generatorExtensions);
}
Expand Down
3 changes: 1 addition & 2 deletions jte/src/main/java/gg/jte/resolve/DirectoryCodeResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.*;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
Expand Down Expand Up @@ -66,7 +65,7 @@ public List<String> resolveAllTemplateNames() {
.filter(p -> !Files.isDirectory(p))
.map(p -> root.relativize(p).toString().replace('\\', '/'))
.filter(IoUtils::isTemplateFile)
.collect(Collectors.toList());
.toList();
} catch (IOException e) {
throw new UncheckedIOException("Failed to resolve all templates in " + root, e);
}
Expand Down
3 changes: 1 addition & 2 deletions jte/src/test/java/gg/jte/migrate/MigrateV1To2Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.stream.Collectors;

import static org.assertj.core.api.Assertions.assertThat;

Expand All @@ -27,7 +26,7 @@ void name(@TempDir Path tempDir) throws IOException {
}

private void copyTemplatesTo(Path tempDir) throws IOException {
List<Path> templates = Files.walk(sourceDirectory).filter(p -> p != sourceDirectory).collect(Collectors.toList());
List<Path> templates = Files.walk(sourceDirectory).filter(p -> p != sourceDirectory).toList();
for (Path template : templates) {
Files.copy(template, tempDir.resolve(template.getFileName()));
}
Expand Down