ControlFlowUtils#statementBreaksLoop; StreamApiMigrationInspection#getInitializerUsageStatus simplified

This commit is contained in:
Tagir Valeev
2016-10-04 09:49:28 +07:00
parent aa583de71b
commit c6cf323132
9 changed files with 182 additions and 8 deletions
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}
@@ -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;
}
}