mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
StreamApiMigrationInspection: use toList()/toSet() collector if target variable type is Collection
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
||||
// "Replace with collect" "true"
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Collect {
|
||||
class Person {
|
||||
String getName() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
void collectNames(List<Person> persons){
|
||||
Collection<String> names = persons.stream().map(Person::getName).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// "Replace with collect" "true"
|
||||
import java.util.*;
|
||||
|
||||
public class Collect {
|
||||
class Person {
|
||||
String getName() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
void collectNames(List<Person> persons){
|
||||
Collection<String> names = new ArrayList<>();
|
||||
for (Person person : pers<caret>ons) {
|
||||
names.add(person.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user