mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 03:13:40 +07:00
IDEA-161002 More anyMatch cases supported with if statement
This commit is contained in:
+16
@@ -0,0 +1,16 @@
|
||||
// "Replace with anyMatch()" "true"
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
public class Main {
|
||||
String contains(String[][] haystack, String needle) {
|
||||
if(haystack != null) {
|
||||
if (Arrays.stream(haystack).filter(Objects::nonNull).flatMap(Arrays::stream).anyMatch(needle::equals)) {
|
||||
return "yes" + needle.length();
|
||||
}
|
||||
System.out.println("oops");
|
||||
}
|
||||
return "no";
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Replace with anyMatch()" "true"
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
public class Main {
|
||||
boolean contains(String[][] haystack, String needle) {
|
||||
if(haystack != null) {
|
||||
if (Arrays.stream(haystack).filter(Objects::nonNull).flatMap(Arrays::stream).anyMatch(needle::equals)) {
|
||||
return true;
|
||||
}
|
||||
System.out.println("Oops");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Replace with anyMatch()" "true"
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
public class Main {
|
||||
void contains(String[][] haystack, String needle) {
|
||||
if(haystack != null) {
|
||||
if (Arrays.stream(haystack).filter(Objects::nonNull).flatMap(Arrays::stream).anyMatch(needle::equals)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// "Replace with anyMatch()" "true"
|
||||
|
||||
public class Main {
|
||||
String contains(String[][] haystack, String needle) {
|
||||
if(haystack != null) {
|
||||
for (String[] row : haysta<caret>ck) {
|
||||
if (row == null) continue;
|
||||
for (String str : row) {
|
||||
if (needle.equals(str))
|
||||
return "yes"+needle.length();
|
||||
}
|
||||
}
|
||||
System.out.println("oops");
|
||||
}
|
||||
return "no";
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// "Replace with anyMatch()" "false"
|
||||
// "Replace with anyMatch()" "true"
|
||||
|
||||
public class Main {
|
||||
boolean contains(String[][] haystack, String needle) {
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// "Replace with anyMatch()" "false"
|
||||
|
||||
public class Main {
|
||||
String contains(String[][] haystack, String needle) {
|
||||
if(haystack != null) {
|
||||
for (String[] row : haysta<caret>ck) {
|
||||
if (row == null) continue;
|
||||
for (String str : row) {
|
||||
if (needle.equals(str))
|
||||
return "yes"+str;
|
||||
}
|
||||
}
|
||||
System.out.println("oops");
|
||||
}
|
||||
return "no";
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Replace with anyMatch()" "true"
|
||||
|
||||
public class Main {
|
||||
void contains(String[][] haystack, String needle) {
|
||||
if(haystack != null) {
|
||||
for (String[] row : haysta<caret>ck) {
|
||||
if (row == null) continue;
|
||||
for (String str : row) {
|
||||
if (needle.equals(str))
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user