mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 15:27:45 +07:00
StreamAPI migration: propose to use any/all/noneMatch if next return is not true/false (using || or &&)
This commit is contained in:
+9
@@ -0,0 +1,9 @@
|
||||
// "Replace with allMatch()" "true"
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
boolean find(List<String> data, boolean other, boolean third) {
|
||||
return data.stream().map(String::trim).allMatch(trimmed -> trimmed.startsWith("xyz")) && (other || third);
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Replace with anyMatch()" "true"
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
boolean find(List<String> data, boolean other, boolean third) {
|
||||
return data.stream().map(String::trim).anyMatch(trimmed -> trimmed.startsWith("xyz")) || (other || third);
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Replace with allMatch()" "true"
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
boolean find(List<String> data, boolean other, boolean third) {
|
||||
for(String e : da<caret>ta) {
|
||||
String trimmed = e.trim();
|
||||
if(!trimmed.startsWith("xyz")) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return other || third;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user