mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
IDEA-160789 Migration to Stream API: replace with mapToInt/Long/Double().sum() when possible
This commit is contained in:
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with sum()" "true"
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Main {
|
||||
public long test(String[] array) {
|
||||
long i = Arrays.stream(array).filter(a -> a.startsWith("xyz")).mapToLong(String::length).sum();
|
||||
return i;
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace with sum()" "true"
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Main {
|
||||
public double test(String[][] array) {
|
||||
double d = 10;
|
||||
d += Arrays.stream(array).filter(arr -> arr != null).flatMap(Arrays::stream).filter(a -> a.startsWith("xyz")).mapToDouble(a -> 1.0 / a.length()).sum();
|
||||
return d;
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Replace with sum()" "true"
|
||||
|
||||
public class Main {
|
||||
public long test(String[] array) {
|
||||
long i = 0;
|
||||
for(String a : ar<caret>ray) {
|
||||
if(a.startsWith("xyz"))
|
||||
i = i + a.length();
|
||||
}
|
||||
return i;
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// "Replace with sum()" "false"
|
||||
|
||||
public class Main {
|
||||
public long test(String[] array) {
|
||||
float i = 0;
|
||||
for(String a : ar<caret>ray) {
|
||||
if(a.startsWith("xyz"))
|
||||
i = i + a.length();
|
||||
}
|
||||
return i;
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// "Replace with sum()" "true"
|
||||
|
||||
public class Main {
|
||||
public double test(String[][] array) {
|
||||
double d = 10;
|
||||
for(String[] arr : arra<caret>y) {
|
||||
if(arr != null) {
|
||||
for (String a : arr) {
|
||||
if (a.startsWith("xyz"))
|
||||
d = d + 1.0/a.length();
|
||||
}
|
||||
}
|
||||
}
|
||||
return d;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user