mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-10 18:09:38 +07:00
replace with collect: insert cast for method reference and simplify when redundant (IDEA-139704)
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
// "Replace with collect" "true"
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
class Test {
|
||||
public static <T> List<TokenFilter<T>> fromString(final T src, Function<T, List<String>> extractor) {
|
||||
final List<TokenFilter<T>> result = extractor.apply(src).stream().map((Function<String, TokenFilter<T>>) TokenFilter::new).collect(Collectors.toList());
|
||||
return result;
|
||||
}
|
||||
|
||||
static class TokenFilter<T> {
|
||||
public TokenFilter(String s) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// "Replace with collect" "true"
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
|
||||
class Test {
|
||||
public static <T> List<TokenFilter<T>> fromString(final T src, Function<T, List<String>> extractor) {
|
||||
final List<TokenFilter<T>> result = new ArrayList<>();
|
||||
for (final String st : extrac<caret>tor.apply(src)) {
|
||||
result.add(new TokenFilter<T>(st));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static class TokenFilter<T> {
|
||||
public TokenFilter(String s) {
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user