foreach -> collect: simplify to addAll on collections if no filter/mapper is present (IDEA-150515)

This commit is contained in:
Anna Kozlova
2016-01-22 14:29:01 +03:00
parent ded792b1f7
commit 5d70440851
5 changed files with 55 additions and 21 deletions
@@ -1,13 +1,12 @@
// "Replace with collect" "true"
// "Replace with addAll" "true"
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
class Sample {
List<String> foo = new ArrayList<>();
String foo(){
Sample sm = new Sample();
sm.foo.addAll(foo.stream().collect(Collectors.toList()));
sm.foo.addAll(foo);
return null;
}
}
@@ -1,11 +1,11 @@
// "Replace with collect" "true"
// "Replace with addAll" "true"
import java.util.*;
import java.util.stream.Collectors;
public class Collect {
class Person {}
void collectNames(List<Person> persons){
List<Person> names = persons.stream().collect(Collectors.toList());
List<Person> names = new ArrayList<>();
names.addAll(persons);
}
}
@@ -1,4 +1,4 @@
// "Replace with collect" "true"
// "Replace with addAll" "true"
import java.util.ArrayList;
import java.util.List;
@@ -1,4 +1,4 @@
// "Replace with collect" "true"
// "Replace with addAll" "true"
import java.util.*;
public class Collect {