mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 00:11:26 +07:00
StreamApiMigrationInspection: support limit count with separate variable
This commit is contained in:
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with findFirst()" "true"
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
public class Main {
|
||||
public String test(String[] array) {
|
||||
return Arrays.stream(array).limit(11).filter(Objects::nonNull).findFirst().orElse("");
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
public Set<String> test(String[] array) {
|
||||
Set<String> set = Arrays.stream(array).filter(Objects::nonNull).limit(10).collect(Collectors.toSet());
|
||||
return set;
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// "Replace with findFirst()" "true"
|
||||
|
||||
public class Main {
|
||||
public String test(String[] array) {
|
||||
int count = 0;
|
||||
for(String str : a<caret>rray) {
|
||||
if (str != null) {
|
||||
return str;
|
||||
}
|
||||
if(++count > 10) return "";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Main {
|
||||
public Set<String> test(String[] array) {
|
||||
int count = 0;
|
||||
Set<String> set = new HashSet<>();
|
||||
for(String str : a<caret>rray) {
|
||||
if (str != null) {
|
||||
set.add(str);
|
||||
if(++count == 10) break;
|
||||
}
|
||||
}
|
||||
return set;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user