Skip to content

Commit 726357b

Browse files
committed
Remove more unneeded Collectors usages
1 parent 005f505 commit 726357b

File tree

6 files changed

+9
-19
lines changed

6 files changed

+9
-19
lines changed

java-compiler-testing/src/main/java/io/github/ascopes/jct/assertions/JctCompilationAssert.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package io.github.ascopes.jct.assertions;
1717

1818
import static java.util.Objects.requireNonNull;
19-
import static java.util.stream.Collectors.toUnmodifiableList;
2019

2120
import io.github.ascopes.jct.compilers.JctCompilation;
2221
import io.github.ascopes.jct.containers.ContainerGroup;
@@ -351,7 +350,7 @@ private AssertionError failWithDiagnostics(
351350
.getDiagnostics()
352351
.stream()
353352
.filter(diagnostic -> kindsToDisplay.contains(diagnostic.getKind()))
354-
.collect(toUnmodifiableList());
353+
.toList();
355354

356355
return failure(
357356
"%s\n\nDiagnostics:\n%s",

java-compiler-testing/src/main/java/io/github/ascopes/jct/assertions/TraceDiagnosticListAssert.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ public TraceDiagnosticListAssert hasNoDiagnosticsOfKinds(Iterable<Kind> kinds) {
294294
var actualDiagnostics = actual
295295
.stream()
296296
.filter(kindIsOneOf(kinds))
297-
.collect(toUnmodifiableList());
297+
.toList();
298298

299299
if (actualDiagnostics.isEmpty()) {
300300
return myself;

java-compiler-testing/src/main/java/io/github/ascopes/jct/assertions/TypeAwareListAssert.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@
1515
*/
1616
package io.github.ascopes.jct.assertions;
1717

18-
import static java.util.stream.Collectors.collectingAndThen;
19-
import static java.util.stream.Collectors.toList;
20-
2118
import java.util.List;
22-
import java.util.function.Function;
2319
import java.util.stream.StreamSupport;
2420
import org.assertj.core.api.AbstractAssert;
2521
import org.assertj.core.api.AbstractListAssert;
@@ -60,12 +56,10 @@ protected A toAssert(@Nullable E value, String description) {
6056
protected TypeAwareListAssert<@Nullable E, A> newAbstractIterableAssert(
6157
Iterable<? extends @Nullable E> iterable
6258
) {
63-
return StreamSupport
59+
var list = StreamSupport
6460
.stream(iterable.spliterator(), false)
65-
.collect(collectingAndThen(toList(), curry()));
66-
}
61+
.toList();
6762

68-
private Function<@Nullable List<@Nullable E>, TypeAwareListAssert<@Nullable E, A>> curry() {
69-
return list -> new TypeAwareListAssert<>(list, assertFactory);
63+
return new TypeAwareListAssert<>(list, assertFactory);
7064
}
7165
}

java-compiler-testing/src/main/java/io/github/ascopes/jct/containers/impl/PathWrappingContainerImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import java.nio.file.Path;
3232
import java.util.Collection;
3333
import java.util.Set;
34-
import java.util.stream.Collectors;
3534
import javax.tools.JavaFileManager.Location;
3635
import javax.tools.JavaFileObject;
3736
import javax.tools.JavaFileObject.Kind;
@@ -160,7 +159,7 @@ public String inferBinaryName(PathFileObject javaFileObject) {
160159
@Override
161160
public Collection<Path> listAllFiles() throws IOException {
162161
try (var walker = Files.walk(root.getPath(), FileVisitOption.FOLLOW_LINKS)) {
163-
return walker.collect(Collectors.toUnmodifiableList());
162+
return walker.toList();
164163
}
165164
}
166165

java-compiler-testing/src/main/java/io/github/ascopes/jct/utils/FileUtils.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package io.github.ascopes.jct.utils;
1717

1818
import static io.github.ascopes.jct.utils.IterableUtils.requireAtLeastOne;
19-
import static java.util.stream.Collectors.toUnmodifiableList;
2019

2120
import io.github.ascopes.jct.ex.JctIllegalInputException;
2221
import java.net.MalformedURLException;
@@ -47,7 +46,7 @@ public final class FileUtils extends UtilityClass {
4746
private static final List<Kind> KINDS = Stream
4847
.of(Kind.values())
4948
.filter(kind -> !kind.extension.isEmpty())
50-
.collect(toUnmodifiableList());
49+
.toList();
5150

5251
private static final StringSlicer PACKAGE_SLICER = new StringSlicer(".");
5352
private static final StringSlicer RESOURCE_SLICER = new StringSlicer("/");
@@ -254,7 +253,7 @@ public static Path resourceNameToPath(Path directory, String packageName, String
254253
/**
255254
* Convert a relative class path resource path to a NIO path.
256255
*
257-
* @param directory the directory the resource sits within.
256+
* @param directory the directory the resource sits within.
258257
* @param pathFragments the path fragments to put together.
259258
* @return the path to the resource on the file system.
260259
*/

java-compiler-testing/src/main/java/io/github/ascopes/jct/utils/SpecialLocationUtils.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.nio.file.Path;
2323
import java.util.List;
2424
import java.util.Set;
25-
import java.util.stream.Collectors;
2625
import org.slf4j.Logger;
2726
import org.slf4j.LoggerFactory;
2827

@@ -116,7 +115,7 @@ private static List<Path> createPaths(String raw) {
116115
// src/main/java do not exist.
117116
.distinct()
118117
.filter(Files::exists)
119-
.collect(Collectors.toUnmodifiableList());
118+
.toList();
120119
}
121120

122121
private static boolean isNotBlank(String string) {

0 commit comments

Comments
 (0)