mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 03:13:40 +07:00
Stream API migration: ignore mutable variables in nested lambdas/anonymous classes; add type argument to map/mapToObj calls where necessary
This commit is contained in:
+1
-1
@@ -5,7 +5,7 @@ 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());
|
||||
final List<TokenFilter<T>> result = extractor.apply(src).stream().<TokenFilter<T>>map(TokenFilter::new).collect(Collectors.toList());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// "Replace with collect" "true"
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
public List<Runnable> test(List<String> list) {
|
||||
List<Runnable> result = list.stream().<Runnable>map(s -> new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String str = s;
|
||||
if (str.isEmpty()) str = "none";
|
||||
System.out.println(str);
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Replace with collect" "true"
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
public List<Runnable> test(List<String> list) {
|
||||
List<Runnable> result = list.stream().<Runnable>map(s -> () -> {
|
||||
String str = s;
|
||||
if (str.isEmpty()) str = "none";
|
||||
System.out.println(str);
|
||||
}).collect(Collectors.toList());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// "Replace with collect" "true"
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
public List<Runnable> test(List<String> list) {
|
||||
List<Runnable> result = new ArrayList<>();
|
||||
for(String s : l<caret>ist) {
|
||||
Runnable r = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String str = s;
|
||||
if (str.isEmpty()) str = "none";
|
||||
System.out.println(str);
|
||||
}
|
||||
};
|
||||
result.add(r);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// "Replace with collect" "true"
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
public List<Runnable> test(List<String> list) {
|
||||
List<Runnable> result = new ArrayList<>();
|
||||
for(String s : li<caret>st) {
|
||||
Runnable r = () -> {
|
||||
String str = s;
|
||||
if (str.isEmpty()) str = "none";
|
||||
System.out.println(str);
|
||||
};
|
||||
result.add(r);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user