mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 15:27:45 +07:00
Inspection: Expression can be folded into Stream chain (IDEA-187123)
This commit is contained in:
+8
@@ -0,0 +1,8 @@
|
||||
import java.util.stream.Stream;
|
||||
|
||||
// "Fold expression into Stream chain" "true"
|
||||
class Test {
|
||||
boolean foo(String a, String b, String c, String d) {
|
||||
return Stream.of(a, b, c, d).allMatch(s -> s.startsWith("xyz"));
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
// "Fold expression into Stream chain" "true"
|
||||
class Test {
|
||||
boolean foo(double[] arr) {
|
||||
return IntStream.of(1, 3, 7, 9).allMatch(i -> arr[i] >= 5);
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import java.util.stream.Stream;
|
||||
|
||||
// "Fold expression into Stream chain" "true"
|
||||
class Test {
|
||||
boolean foo(String a, String b, String c, String d) {
|
||||
return Stream.of(a, b, c, d).noneMatch(s -> s.startsWith("xyz"));
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
// "Fold expression into Stream chain" "true"
|
||||
class Test {
|
||||
String foo(String a, String b, String c, String d) {
|
||||
return Stream.of(a, b, c, d).map(String::trim).collect(Collectors.joining());
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
// "Fold expression into Stream chain" "true"
|
||||
class Test {
|
||||
String foo(int a, int b, int c, int d) {
|
||||
return IntStream.of(a, b, c, d).map(i -> i * 2).mapToObj(String::valueOf).collect(Collectors.joining("|"));
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import java.util.stream.Stream;
|
||||
|
||||
// "Fold expression into Stream chain" "true"
|
||||
class Test {
|
||||
boolean foo(String a, String b, String c, String d) {
|
||||
return Stream.of(a, b, c, d).noneMatch(s -> s.startsWith("xyz"));
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import java.util.stream.Stream;
|
||||
|
||||
// "Fold expression into Stream chain" "true"
|
||||
class Test {
|
||||
int foo(String a, String b, String c, String d) {
|
||||
return Stream.of(a, b, c, d).mapToInt(String::length).sum();
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// "Fold expression into Stream chain" "true"
|
||||
class Test {
|
||||
boolean foo(String a, String b, String c, String d) {
|
||||
return a.startsWith("xyz") &<caret>& b.startsWith("xyz") && c.startsWith("xyz") && d.startsWith("xyz");
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// "Fold expression into Stream chain" "true"
|
||||
class Test {
|
||||
boolean foo(double[] arr) {
|
||||
return arr[1] >= 5 && arr[3] >= 5 && arr[7] >= 5 && arr[9] <caret>>= 5;
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// "Fold expression into Stream chain" "true"
|
||||
class Test {
|
||||
boolean foo(String a, String b, String c, String d) {
|
||||
return !a.startsWith("xyz") &<caret>& !b.startsWith("xyz") && !c.startsWith("xyz") && !d.startsWith("xyz");
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// "Fold expression into Stream chain" "true"
|
||||
class Test {
|
||||
String foo(String a, String b, String c, String d) {
|
||||
return a.trim()+b.trim()+c.trim()+<caret>d.trim();
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// "Fold expression into Stream chain" "true"
|
||||
class Test {
|
||||
String foo(int a, int b, int c, int d) {
|
||||
return a * 2 + "|" + b * 2 + "|" + c * 2 + "|"<caret> + d * 2;
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// "Fold expression into Stream chain" "true"
|
||||
class Test {
|
||||
boolean foo(String a, String b, String c, String d) {
|
||||
return !(a.startsWith("xyz") |<caret>| b.startsWith("xyz") || c.startsWith("xyz") || d.startsWith("xyz"));
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// "Fold expression into Stream chain" "false"
|
||||
class Test {
|
||||
boolean foo(String a, String b, String c, String d) {
|
||||
return a == null || b == null || c == null || d == <caret>null;
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// "Fold expression into Stream chain" "true"
|
||||
class Test {
|
||||
int foo(String a, String b, String c, String d) {
|
||||
return a.length()+b.length()+c.length()+<caret>d.length();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user