EnsureCodeBlock: support or-chains in return/lambdas

This commit is contained in:
Tagir Valeev
2018-10-18 12:53:10 +07:00
parent c77f5f16eb
commit e79ea86e18
6 changed files with 89 additions and 26 deletions

View File

@@ -0,0 +1,17 @@
// "Replace Stream API chain with loop" "true"
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
public class Main {
public boolean testCond(List<String> list) {
if (list.stream().noneMatch(String::isEmpty)) return false;
for (String s : list) {
if (s == null) {
return true;
}
}
return false;
}
}

View File

@@ -0,0 +1,17 @@
// "Replace Stream API chain with loop" "true"
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
public class Main {
public boolean testCond(List<String> list) {
if (list.stream().anyMatch(String::isEmpty)) return true;
for (String s : list) {
if (s == null) {
return true;
}
}
return false;
}
}

View File

@@ -0,0 +1,11 @@
// "Replace Stream API chain with loop" "true"
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
public class Main {
public boolean testCond(List<String> list) {
return list.stream().anyMatch(String::isEmpty) && list.stream().any<caret>Match(Objects::isNull);
}
}

View File

@@ -0,0 +1,11 @@
// "Replace Stream API chain with loop" "true"
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
public class Main {
public boolean testCond(List<String> list) {
return list.stream().anyMatch(String::isEmpty) || list.stream().any<caret>Match(Objects::isNull);
}
}