IDEA-167088 Stream API migration: support simple joining cases

This commit is contained in:
Tagir Valeev
2017-01-25 12:46:01 +07:00
parent 6df4c04c39
commit 16ddd276ed
6 changed files with 149 additions and 1 deletions
@@ -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;
}
}
@@ -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();
}
}
@@ -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();
}
}
@@ -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();
}
}
@@ -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();
}
}