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

Replace .collect(toList()) with .toList() #12978

Merged
merged 1 commit into from
Dec 30, 2023
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
2 changes: 1 addition & 1 deletion dev-tools/scripts/StageArtifacts.java
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ public static void main(String[] args) throws Exception {
// Ignore locally generated maven metadata files.
.filter(path -> !path.getFileName().toString().startsWith("maven-metadata."))
.sorted(Comparator.comparing(Path::toString))
.collect(Collectors.toList());
.toList();
}

// Figure out nexus profile ID based on POMs. It is assumed that all artifacts
Expand Down
2 changes: 1 addition & 1 deletion gradle/generation/extract-jdk-apis/ExtractJdkApis.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static void main(String... args) throws IOException {
// Collect all files to process:
final List<Path> filesToExtract;
try (var stream = Files.walk(jrtPath)) {
filesToExtract = stream.filter(p -> pattern.matches(jrtPath.relativize(p))).collect(Collectors.toList());
filesToExtract = stream.filter(p -> pattern.matches(jrtPath.relativize(p))).toList();
}

// Process all class files:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,15 @@ public class TestRandomChains extends BaseTokenStreamTestCase {

private static final Map<Class<?>, Function<Random, Object>> argProducers =
Collections.unmodifiableMap(
new IdentityHashMap<Class<?>, Function<Random, Object>>() {
new IdentityHashMap<>() {
{
put(
int.class,
random -> {
// TODO: could cause huge ram usage to use full int range for some filters
// (e.g. allocate enormous arrays)
// return Integer.valueOf(random.nextInt());
return Integer.valueOf(TestUtil.nextInt(random, -50, 50));
return TestUtil.nextInt(random, -50, 50);
});
put(
char.class,
Expand All @@ -187,7 +187,7 @@ public class TestRandomChains extends BaseTokenStreamTestCase {
while (true) {
char c = (char) random.nextInt(65536);
if (c < '\uD800' || c > '\uDFFF') {
return Character.valueOf(c);
return c;
}
}
});
Expand Down Expand Up @@ -382,7 +382,7 @@ public class TestRandomChains extends BaseTokenStreamTestCase {
});
put(
SynonymMap.class,
new Function<Random, Object>() {
new Function<>() {
@Override
public Object apply(Random random) {
SynonymMap.Builder b = new SynonymMap.Builder(random.nextBoolean());
Expand Down Expand Up @@ -448,12 +448,11 @@ private String randomNonEmptyString(Random random) {
});
put(
Automaton.class,
random -> {
return Operations.determinize(
new RegExp(AutomatonTestUtil.randomRegexp(random), RegExp.NONE)
.toAutomaton(),
Operations.DEFAULT_DETERMINIZE_WORK_LIMIT);
});
random ->
Operations.determinize(
new RegExp(AutomatonTestUtil.randomRegexp(random), RegExp.NONE)
.toAutomaton(),
Operations.DEFAULT_DETERMINIZE_WORK_LIMIT));
put(
PatternTypingFilter.PatternTypingRule[].class,
random -> {
Expand Down Expand Up @@ -625,9 +624,9 @@ public static void beforeClass() throws Exception {
}

final Comparator<Constructor<?>> ctorComp = Comparator.comparing(Constructor::toGenericString);
Collections.sort(tokenizers, ctorComp);
Collections.sort(tokenfilters, ctorComp);
Collections.sort(charfilters, ctorComp);
tokenizers.sort(ctorComp);
tokenfilters.sort(ctorComp);
charfilters.sort(ctorComp);
if (VERBOSE) {
System.out.println("tokenizers = " + tokenizers);
System.out.println("tokenfilters = " + tokenfilters);
Expand All @@ -642,7 +641,7 @@ public static void beforeClass() throws Exception {
.filter(c -> c.getName().endsWith("Stemmer"))
.map(stemmerCast)
.sorted(Comparator.comparing(Class::getName))
.collect(Collectors.toList());
.toList();
if (VERBOSE) {
System.out.println("snowballStemmers = " + snowballStemmers);
}
Expand Down Expand Up @@ -786,7 +785,7 @@ private <T> T createComponent(
if (cause instanceof IllegalArgumentException
|| (cause instanceof NullPointerException && Stream.of(args).anyMatch(Objects::isNull))
|| cause instanceof UnsupportedOperationException) {
// thats ok, ignore
// that's ok, ignore
if (VERBOSE) {
System.err.println("Ignoring IAE/UOE/NPE from ctor:");
cause.printStackTrace(System.err);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.util.TreeSet;
import java.util.function.Consumer;
import java.util.function.IntPredicate;
import java.util.stream.Collectors;
import org.apache.lucene.util.CharsRef;
import org.apache.lucene.util.IntsRef;
import org.apache.lucene.util.fst.FST;
Expand Down Expand Up @@ -108,7 +107,7 @@ private List<Weighted<Root<String>>> findSimilarDictionaryEntries(
}
});

return roots.stream().sorted().collect(Collectors.toList());
return roots.stream().sorted().toList();
}

private static boolean isWorseThan(int score, CharsRef candidate, Weighted<Root<String>> root) {
Expand Down Expand Up @@ -141,7 +140,7 @@ private List<Weighted<String>> expandRoots(
}
}
}
return expanded.stream().limit(MAX_GUESSES).collect(Collectors.toList());
return expanded.stream().limit(MAX_GUESSES).toList();
}

// find minimum threshold for a passable suggestion
Expand Down Expand Up @@ -223,7 +222,7 @@ && checkAffixCondition(prefixId, wordChars, stripLength, stemLength)) {
}
});

return result.stream().limit(MAX_WORDS).collect(Collectors.toList());
return result.stream().limit(MAX_WORDS).toList();
}

private void processAffixes(boolean prefixes, String word, AffixProcessor processor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.lucene.util.CharsRef;
import org.apache.lucene.util.IntsRef;

Expand Down Expand Up @@ -304,10 +303,7 @@ private boolean hasForceUCaseProblem(Root<?> root, WordCase originalCase, char[]
* Dictionary#lookupEntries}.
*/
public List<String> getRoots(String word) {
return stemmer.stem(word).stream()
.map(CharsRef::toString)
.distinct()
.collect(Collectors.toList());
return stemmer.stem(word).stream().map(CharsRef::toString).distinct().toList();
}

/**
Expand Down
Loading
Loading