support return in forEach replacement

This commit is contained in:
Roman Ivanov
2017-09-01 12:37:18 +07:00
parent 5acdc9ccdc
commit c3b4d6f849
8 changed files with 53 additions and 18 deletions
@@ -0,0 +1,14 @@
// "Replace with forEach" "true"
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
class Sample {
List<String> foo = new ArrayList<>();
{
foo.stream().filter(Objects::isNull).forEach(s -> {
return;
});
}
}
@@ -0,0 +1,14 @@
// "Replace with forEach" "true"
import java.util.Arrays;
import java.util.Collection;
public class Test {
void test(int[] arr) {
Arrays.stream(arr).forEach(x -> {
int y = x * 2;
if (x > y) return;
System.out.println(x);
});
}
}
@@ -1,4 +1,4 @@
// "Replace with forEach" "false"
// "Replace with forEach" "true"
import java.util.ArrayList;
import java.util.List;
@@ -12,4 +12,4 @@ class Sample {
}
}
}
}
@@ -1,13 +0,0 @@
// "Replace with forEach" "true"
import java.util.Collection;
public class Test {
void test(int[] arr) {
for<caret>(int x : arr) {
int y = x*2;
if(x > y) continue;
System.out.println(x);
}
}
}