StreamApiMigrationInspection: support postfix limit conversion (like if(count++ > 100) break; => limit(102)) (IDEA-CR-16910)

This commit is contained in:
Tagir Valeev
2016-12-21 13:45:42 +07:00
parent fa956bd50c
commit 6341a52ccd
3 changed files with 40 additions and 12 deletions
@@ -0,0 +1,10 @@
// "Replace with count()" "true"
import java.util.Arrays;
public class Main {
public long test(String[] array) {
long longStrings = Arrays.stream(array).map(String::trim).filter(trimmed -> trimmed.length() > 10).limit(102).count();
return longStrings;
}
}
@@ -0,0 +1,14 @@
// "Replace with count()" "true"
public class Main {
public long test(String[] array) {
long longStrings = 0;
for(String str : a<caret>rray) {
String trimmed = str.trim();
if(trimmed.length() > 10) {
if(longStrings++ > 100) break;
}
}
return longStrings;
}
}