Skip to content

Commit

Permalink
Remove usages of Collectors.toList()
Browse files Browse the repository at this point in the history
  • Loading branch information
ascopes committed Dec 26, 2024
1 parent d4aa7b1 commit 92e84bc
Show file tree
Hide file tree
Showing 16 changed files with 22 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package io.github.ascopes.jct.compilers.impl;

import static java.util.Objects.requireNonNull;
import static java.util.stream.Collectors.toList;

import io.github.ascopes.jct.compilers.JctCompilation;
import io.github.ascopes.jct.compilers.JctCompilationFactory;
Expand Down Expand Up @@ -139,7 +138,7 @@ public JctCompilation createCompilation(
.arguments(flags)
.compilationUnits(Set.copyOf(compilationUnits))
.fileManager(fileManager)
.outputLines(writer.getContent().lines().collect(toList()))
.outputLines(writer.getContent().lines().toList())
.diagnostics(diagnosticListener.getDiagnostics())
.success(success)
.failOnWarnings(compiler.isFailOnWarnings())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,3 @@
*/
package io.github.ascopes.jct.ex;

import org.apiguardian.api.API;
import org.apiguardian.api.API.Status;
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,3 @@
*/
package io.github.ascopes.jct.filemanagers.config;

import org.apiguardian.api.API;
import org.apiguardian.api.API.Status;
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import io.github.ascopes.jct.ex.JctIllegalInputException;
import io.github.ascopes.jct.ex.JctJunitConfigurerException;
import java.lang.reflect.Constructor;
import java.lang.reflect.InaccessibleObjectException;
import java.lang.reflect.InvocationTargetException;
import java.util.stream.IntStream;
import java.util.stream.Stream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.util.List;
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
import me.xdrop.fuzzywuzzy.FuzzySearch;
import me.xdrop.fuzzywuzzy.ToStringFunction;
import me.xdrop.fuzzywuzzy.model.BoundExtractedResult;
Expand Down Expand Up @@ -282,7 +281,7 @@ public static <T> String resultNotFoundWithFuzzySuggestions(
.map(BoundExtractedResult::getReferent)
.map(userFriendlyStringifier)
.sorted()
.collect(Collectors.toList());
.toList();

if (!closestMatches.isEmpty()) {
errorBuilder.append(" Maybe you meant:");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import io.github.ascopes.jct.compilers.DebuggingInfo;
import io.github.ascopes.jct.fixtures.Fixtures;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
Expand Down Expand Up @@ -467,7 +466,7 @@ void addsAnnotationProcessorOptions() {
var options = Stream
.generate(Fixtures::someText)
.limit(5)
.collect(Collectors.toList());
.toList();

// When
flagBuilder.annotationProcessorOptions(options);
Expand All @@ -476,7 +475,7 @@ void addsAnnotationProcessorOptions() {
assertThat(flagBuilder.build())
.containsSequence(options.stream()
.map("-A"::concat)
.collect(Collectors.toList()));
.toList());
}

@DisplayName(".annotationProcessorOptions(...) returns the flag builder")
Expand All @@ -486,7 +485,7 @@ void returnsFlagBuilder() {
var options = Stream
.generate(Fixtures::someText)
.limit(5)
.collect(Collectors.toList());
.toList();

// Then
assertThat(flagBuilder.annotationProcessorOptions(options))
Expand All @@ -505,7 +504,7 @@ void addsCompilerOptions() {
var options = Stream
.generate(Fixtures::someText)
.limit(5)
.collect(Collectors.toList());
.toList();

// When
flagBuilder.compilerOptions(options);
Expand All @@ -522,7 +521,7 @@ void returnsFlagBuilder() {
var options = Stream
.generate(Fixtures::someText)
.limit(5)
.collect(Collectors.toList());
.toList();

// Then
assertThat(flagBuilder.compilerOptions(options))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import static io.github.ascopes.jct.fixtures.Fixtures.someText;
import static io.github.ascopes.jct.fixtures.Fixtures.someTraceDiagnostic;
import static io.github.ascopes.jct.utils.IterableUtils.flatten;
import static java.util.stream.Collectors.toList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
Expand Down Expand Up @@ -388,7 +387,7 @@ void teeWriterLogsShouldBePlacedInTheCompilationResult() throws IOException {

// Then
assertThat(result.getOutputLines())
.containsExactlyElementsOf(lines.lines().collect(toList()));
.containsExactlyElementsOf(lines.lines().toList());

// Ensure we flushed before we called toString, otherwise data might be missing.
order.verify(teeWriter).flush();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void getArgumentsReturnsExpectedValue(int argumentCount) {
var arguments = Stream
.generate(Fixtures::someFlag)
.limit(argumentCount)
.collect(Collectors.toList());
.toList();

var compilation = filledBuilder()
.arguments(arguments)
Expand Down Expand Up @@ -102,7 +102,7 @@ void getOutputLinesReturnsExpectedValue(int lineCount) {
.generate(UUID::randomUUID)
.map(Objects::toString)
.limit(lineCount)
.collect(Collectors.toList());
.toList();

var compilation = filledBuilder()
.outputLines(lines)
Expand Down Expand Up @@ -141,7 +141,7 @@ void getDiagnosticsReturnsExpectedValue(int diagnosticCount) {
var diagnostics = Stream
.generate(Fixtures::someTraceDiagnostic)
.limit(diagnosticCount)
.collect(Collectors.toList());
.toList();

var compilation = filledBuilder()
.diagnostics(diagnostics)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ void addPathsDelegatesMultipleCallsToTheRepository() {
var pathRoots = Stream
.generate(Fixtures::somePathRoot)
.limit(10)
.collect(Collectors.toList());
.toList();

// When
fileManager.addPaths(location, pathRoots);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import java.util.Random;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.tools.Diagnostic;
import javax.tools.Diagnostic.Kind;
Expand Down Expand Up @@ -180,7 +179,7 @@ public static List<String> someFlags() {
return Stream
.generate(Fixtures::someFlag)
.limit(someInt(2, 4))
.collect(Collectors.toList());
.toList();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import io.github.ascopes.jct.ex.JctJunitConfigurerException;
import io.github.ascopes.jct.fixtures.Fixtures;
import java.lang.reflect.InvocationTargetException;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -131,7 +130,7 @@ void configuringTheProviderRespectsTheMinimumVersionBound() {
provider.configureInternals(10, 17, versionStrategy);
var compilers = provider.provideArguments(mock(ExtensionContext.class))
.map(args -> (JctCompiler) args.get()[0])
.collect(Collectors.toList());
.toList();

// Then
assertThat(compilers).hasSize(3);
Expand All @@ -155,7 +154,7 @@ void configuringTheProviderRespectsTheMaximumVersionBound() {
provider.configureInternals(15, 20, versionStrategy);
var compilers = provider.provideArguments(mock(ExtensionContext.class))
.map(args -> (JctCompiler) args.get()[0])
.collect(Collectors.toList());
.toList();

// Then
assertThat(compilers).hasSize(3);
Expand Down Expand Up @@ -185,7 +184,7 @@ void configuringTheProviderWithConfigurersWillUseConfigurers() {
);
var compilers = provider.provideArguments(mock(ExtensionContext.class))
.map(args -> (JctCompiler) args.get()[0])
.collect(Collectors.toList());
.toList();

// Then
assertSoftly(softly -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import io.github.ascopes.jct.compilers.JctCompilerConfigurer;
import io.github.ascopes.jct.compilers.impl.JavacJctCompilerImpl;
import java.lang.reflect.AnnotatedElement;
import java.util.stream.Collectors;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtensionContext;
Expand All @@ -51,7 +50,7 @@ void providerUsesTheUserProvidedVersionRangesWhenValid() {
var consumer = initialize(test, new JavacCompilersProvider());
var compilers = consumer.provideArguments(context)
.map(args -> (JavacJctCompilerImpl) args.get()[0])
.collect(Collectors.toList());
.toList();

// Then
assertThat(compilers)
Expand Down Expand Up @@ -87,7 +86,7 @@ void providerUsesTheMinCompilerVersionAllowedIfExceeded() {
var consumer = initialize(test, new JavacCompilersProvider());
var compilers = consumer.provideArguments(context)
.map(args -> (JavacJctCompilerImpl) args.get()[0])
.collect(Collectors.toList());
.toList();

// Then
assertThat(compilers)
Expand Down Expand Up @@ -123,7 +122,7 @@ void providerUsesTheMaxCompilerVersionAllowedIfExceeded() {
var consumer = initialize(test, new JavacCompilersProvider());
var compilers = consumer.provideArguments(context)
.map(args -> (JavacJctCompilerImpl) args.get()[0])
.collect(Collectors.toList());
.toList();

// Then
assertThat(compilers)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ private List<Path> allExcept(Path... excludedPaths) {
return paths
.stream()
.filter(not(List.of(excludedPaths)::contains))
.collect(Collectors.toList());
.toList();
}

private String toPathString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import static org.assertj.core.api.BDDAssertions.thenCode;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -82,7 +81,7 @@ void slicingStringIntoStreamReturnsTheExpectedResult(
// When
var actual = slicer
.splitToStream(input)
.collect(Collectors.toList());
.toList();

// Then
then(actual).isEqualTo(expected);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
Expand All @@ -54,7 +53,7 @@ void theClassIsSingleton() {
var instances = Stream
.generate(MemoryFileSystemProvider::getInstance)
.limit(10)
.collect(Collectors.toList());
.toList();

// Then
assertThat(instances)
Expand Down

0 comments on commit 92e84bc

Please sign in to comment.