mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-25 19:29:30 +07:00
ControlFlowUtils#statementBreaksLoop; StreamApiMigrationInspection#getInitializerUsageStatus simplified
This commit is contained in:
+17
@@ -0,0 +1,17 @@
|
||||
// "Replace with anyMatch()" "true"
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
public boolean testAnyMatch(List<List<String>> data) {
|
||||
if (!data.isEmpty()) {
|
||||
if (data.stream().flatMap(Collection::stream).anyMatch(str -> !str.isEmpty())) {
|
||||
System.out.println("Found!");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Replace with findFirst()" "true"
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
public List<Integer> testFindFirstIfPresent(List<List<String>> data) {
|
||||
List<Integer> result = new ArrayList<>();
|
||||
if (!data.isEmpty()) {
|
||||
data.stream().flatMap(Collection::stream).filter(str -> !str.isEmpty()).findFirst().ifPresent(str -> result.add(str.length()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// "Replace with anyMatch()" "true"
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
public boolean testAnyMatch(List<List<String>> data) {
|
||||
if (!data.isEmpty()) {
|
||||
for (List<String> list : dat<caret>a) {
|
||||
for (String str : list) {
|
||||
if (!str.isEmpty()) {
|
||||
System.out.println("Found!");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// "Replace with anyMatch()" "false"
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
public boolean testAnyMatch(List<List<String>> data) {
|
||||
if (!data.isEmpty()) {
|
||||
for (List<String> list : dat<caret>a) {
|
||||
for (String str : list) {
|
||||
if (!str.isEmpty()) {
|
||||
System.out.println("Found!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// "Replace with anyMatch()" "false"
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
public boolean testAnyMatch(List<List<String>> data) {
|
||||
if (!data.isEmpty()) {
|
||||
for (List<String> list : dat<caret>a) {
|
||||
for (String str : list) {
|
||||
if (!str.isEmpty()) {
|
||||
System.out.println("Found!");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("Oops");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// "Replace with findFirst()" "true"
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
public List<Integer> testFindFirstIfPresent(List<List<String>> data) {
|
||||
List<Integer> result = new ArrayList<>();
|
||||
if (!data.isEmpty()) {
|
||||
for (List<String> list : da<caret>ta) {
|
||||
for (String str : list) {
|
||||
if (!str.isEmpty()) {
|
||||
result.add(str.length());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user