IDEA-161259 Add Java-8 migration to use Collection.removeIf() where appropriate

This commit is contained in:
Tagir Valeev
2016-09-27 17:48:38 +07:00
parent 87bf9386d3
commit bee98f0f07
9 changed files with 235 additions and 7 deletions
@@ -0,0 +1,8 @@
// "Replace the loop with Collection.removeIf" "true"
import java.util.*;
public class Main {
public void removeEmpty(List<String> list) throws Exception {
list.removeIf(String::isEmpty);
}
}
@@ -0,0 +1,9 @@
// "Replace the loop with Collection.removeIf" "true"
import java.util.*;
public class Main {
public void removeEmpty(List<String> list) throws Exception {
// remove empty
list.removeIf(String::isEmpty);
}
}
@@ -0,0 +1,13 @@
// "Replace the loop with Collection.removeIf" "true"
import java.util.*;
public class Main {
public void removeEmpty(List<String> list) throws Exception {
f<caret>or(Iterator<String> it = list.iterator(); it.hasNext();) {
String str = it.next();
if(str.isEmpty()) {
it.remove();
}
}
}
}
@@ -0,0 +1,15 @@
// "Replace the loop with Collection.removeIf" "true"
import java.util.*;
public class Main {
public void removeEmpty(List<String> list) throws Exception {
Iterator<String> it = list.iterator();
while<caret>(it.hasNext()) {
String str = it.next();
// remove empty
if(str.isEmpty()) {
it.remove();
}
}
}
}
@@ -0,0 +1,16 @@
// "Replace the loop with Collection.removeIf" "false"
import java.util.*;
public class Main {
public void removeEmpty(List<String> list) throws Exception {
Iterator<String> it = list.iterator();
while<caret>(it.hasNext()) {
String str = it.next();
// remove empty
if(str.isEmpty()) {
it.remove();
}
}
it = list.iterator();
}
}