IDEA-167088 Stream API migration: allow resulting StringBuilder usages in concatenation

This commit is contained in:
Tagir Valeev
2017-01-25 14:36:47 +07:00
parent c6d3728f9f
commit 5f29e676e6
3 changed files with 44 additions and 0 deletions
@@ -0,0 +1,16 @@
// "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()).map(String::trim).collect(Collectors.joining());
String s = "Result: ";
s += sb;
System.out.println(s);
return "[" + sb + "]";
}
}
@@ -0,0 +1,19 @@
// "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.trim());
}
}
String s = "Result: ";
s += sb;
System.out.println(s);
return "[" + sb + "]";
}
}