Replace Collectors.toList with Stream.toList

Closes gh-29203
This commit is contained in:
Adam Ostrožlík
2022-09-26 14:04:43 +02:00
committed by Brian Clozel
parent 9d263668d5
commit 0ccb64fe10
49 changed files with 62 additions and 106 deletions

View File

@@ -22,7 +22,6 @@ import java.lang.annotation.RetentionPolicy;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Test;
@@ -95,7 +94,7 @@ class MergedAnnotationPredicatesTests {
List<MergedAnnotation<TestAnnotation>> filtered = MergedAnnotations.from(
WithMultipleTestAnnotation.class).stream(TestAnnotation.class).filter(
MergedAnnotationPredicates.firstRunOf(
this::firstCharOfValue)).collect(Collectors.toList());
this::firstCharOfValue)).toList();
assertThat(filtered.stream().map(
annotation -> annotation.getString("value"))).containsExactly("a1", "a2", "a3");
}
@@ -111,7 +110,7 @@ class MergedAnnotationPredicatesTests {
List<MergedAnnotation<TestAnnotation>> filtered = MergedAnnotations.from(
WithMultipleTestAnnotation.class).stream(TestAnnotation.class).filter(
MergedAnnotationPredicates.unique(
this::firstCharOfValue)).collect(Collectors.toList());
this::firstCharOfValue)).toList();
assertThat(filtered.stream().map(
annotation -> annotation.getString("value"))).containsExactly("a1", "b1", "c1");
}

View File

@@ -33,7 +33,6 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import jakarta.annotation.Resource;
@@ -1896,7 +1895,7 @@ class MergedAnnotationsTests {
Adapt.ANNOTATION_TO_MAP);
Map<String, Object>[] filters = (Map[]) map.get("excludeFilters");
List<String> patterns = Arrays.stream(filters).map(
m -> (String) m.get("pattern")).collect(Collectors.toList());
m -> (String) m.get("pattern")).toList();
assertThat(patterns).containsExactly("*Foo", "*Bar");
filters[0].put("pattern", "newFoo");
filters[0].put("enigma", 42);