mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 03:13:40 +07:00
IDEA-167088 Stream API migration: support simple joining cases
This commit is contained in:
+13
@@ -0,0 +1,13 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Test {
|
||||
static String test(List<String> list) {
|
||||
String sb;
|
||||
System.out.println("hello");
|
||||
sb = list.stream().filter(s -> !s.isEmpty()).collect(Collectors.joining());
|
||||
return sb.length() == 0 ? null : sb;
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Test {
|
||||
static String test(List<String> list) {
|
||||
String sb = list.stream().filter(s -> !s.isEmpty()).collect(Collectors.joining());
|
||||
String s = sb;
|
||||
return s.trim();
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Test {
|
||||
static String test(List<String> list) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
System.out.println("hello");
|
||||
for(String s : li<caret>st) {
|
||||
if(!s.isEmpty()) {
|
||||
sb.append(s);
|
||||
}
|
||||
}
|
||||
return sb.length() == 0 ? null : sb.toString();
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Test {
|
||||
static String test(List<String> list) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for(String s : li<caret>st) {
|
||||
if(!s.isEmpty()) {
|
||||
sb.append(s);
|
||||
}
|
||||
}
|
||||
String s = sb.toString();
|
||||
return s.trim();
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// "Replace with collect" "false"
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Test {
|
||||
static String test(List<String> list) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
System.out.println("hello");
|
||||
for(String s : li<caret>st) {
|
||||
if(!s.isEmpty()) {
|
||||
sb.append(s);
|
||||
}
|
||||
}
|
||||
sb.append("xyz");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user