stream migration inspection: collapse only primitive new initializers (IDEA-121745)

This commit is contained in:
Anna Kozlova
2014-03-06 15:30:22 +01:00
parent 90d07400e1
commit b060c817e0
3 changed files with 53 additions and 6 deletions
@@ -0,0 +1,20 @@
// "Replace with collect" "true"
import java.util.*;
import java.util.stream.Collectors;
public class Collect {
class Person {
String getName() {
return "";
}
}
ArrayList<String> foo() {
return new ArrayList<>();
}
void collectNames(List<Person> persons){
List<String> names = foo();
names.addAll(persons.stream().map(Person::getName).collect(Collectors.toList()));
}
}
@@ -0,0 +1,21 @@
// "Replace with collect" "true"
import java.util.*;
public class Collect {
class Person {
String getName() {
return "";
}
}
ArrayList<String> foo() {
return new ArrayList<>();
}
void collectNames(List<Person> persons){
List<String> names = foo();
for (Person person : pers<caret>ons) {
names.add(person.getName());
}
}
}