mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 00:11:26 +07:00
StreamApiMigrationInspection: refactoring of collect scenarios: CollectTerminal interface extracted and used; all forEach scenarios moved to ForEachMigration; cosmetics
This commit is contained in:
+2
-2
@@ -8,8 +8,8 @@ public class Collect {
|
||||
}
|
||||
}
|
||||
|
||||
Set<String> names = new HashSet<>();
|
||||
final Set<String> names = new HashSet<>();
|
||||
void collectNames(List<Person> persons){
|
||||
persons.stream().map(Person::getName).forEach(s -> names.add(s));
|
||||
persons.stream().map(Person::getName).forEach(names::add);
|
||||
}
|
||||
}
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Replace with toArray" "true"
|
||||
import java.util.*;
|
||||
|
||||
public class Test {
|
||||
String[] test(List<String> list) {
|
||||
return list.stream().filter(Objects::nonNull).sorted(String.CASE_INSENSITIVE_ORDER).toArray(String[]::new);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -8,7 +8,7 @@ public class Collect {
|
||||
}
|
||||
}
|
||||
|
||||
Set<String> names = new HashSet<>();
|
||||
final Set<String> names = new HashSet<>();
|
||||
void collectNames(List<Person> persons){
|
||||
for (Person person : pers<caret>ons) {
|
||||
names.add(person.getName());
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import java.util.*;
|
||||
class A {
|
||||
void fun(List<String>... lists) {
|
||||
for (List<String> list : li<caret>sts) {
|
||||
System.out.println(list);
|
||||
list.add("");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Replace with toArray" "true"
|
||||
import java.util.*;
|
||||
|
||||
public class Test {
|
||||
String[] test(List<String> list) {
|
||||
List<String> result = new LinkedList<>();
|
||||
for(String str : li<caret>st) {
|
||||
if(str != null) {
|
||||
result.add(str);
|
||||
}
|
||||
}
|
||||
result.sort(String.CASE_INSENSITIVE_ORDER);
|
||||
return result.toArray(new String[0]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user