IDEA-160946 Labeled continue is excluded; understand if(..) continue else {...}; more tests

This commit is contained in:
Tagir Valeev
2016-09-09 11:22:00 +07:00
parent bcc0990204
commit 6d5901be86
6 changed files with 108 additions and 7 deletions
@@ -0,0 +1,12 @@
// "Replace with collect" "true"
import java.util.*;
import java.util.stream.Collectors;
public class Main {
public List<String> test(Map<String, List<String>> map) {
List<String> result = map.entrySet().stream().filter(entry -> !entry.getKey().isEmpty()).map(Map.Entry::getValue).filter(Objects::nonNull).flatMap(Collection::stream).map(String::trim).filter(trimmed -> !trimmed.isEmpty()).collect(Collectors.toList());
return result;
}
}
@@ -0,0 +1,12 @@
// "Replace with collect" "true"
import java.util.*;
import java.util.stream.Collectors;
public class Main {
public List<String> test(Map<String, List<String>> map) {
List<String> result = map.entrySet().stream().filter(entry -> !entry.getKey().isEmpty()).map(Map.Entry::getValue).filter(Objects::nonNull).flatMap(Collection::stream).map(String::trim).filter(trimmed -> !trimmed.isEmpty()).collect(Collectors.toList());
return result;
}
}
@@ -0,0 +1,23 @@
// "Replace with collect" "true"
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class Main {
public List<String> test(Map<String, List<String>> map) {
List<String> result = new ArrayList<>();
for(Map.Entry<String, List<String>> entry : map.en<caret>trySet()) {
if(entry.getKey().isEmpty()) continue;
List<String> list = entry.getValue();
if(list == null) continue;
for(String str : list) {
String trimmed = str.trim();
if(trimmed.isEmpty()) continue;
result.add(trimmed);
}
}
return result;
}
}
@@ -0,0 +1,25 @@
// "Replace with collect" "true"
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class Main {
public List<String> test(Map<String, List<String>> map) {
List<String> result = new ArrayList<>();
for(Map.Entry<String, List<String>> entry : map.en<caret>trySet()) {
if(entry.getKey().isEmpty()) continue;
else {
List<String> list = entry.getValue();
if (list == null) continue;
for (String str : list) {
String trimmed = str.trim();
if (trimmed.isEmpty()) continue;
else result.add(trimmed);
}
}
}
return result;
}
}
@@ -0,0 +1,24 @@
// "Replace with forEach" "false"
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class Main {
public List<String> test(Map<String, List<String>> map) {
List<String> result = new ArrayList<>();
outer:
for(Map.Entry<String, List<String>> entry : map.ent<caret>rySet()) {
if(entry.getKey().isEmpty()) continue;
List<String> list = entry.getValue();
if(list == null) continue;
for(String str : list) {
String trimmed = str.trim();
if(trimmed.isEmpty()) continue outer;
result.add(trimmed);
}
}
return result;
}
}