mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-10 13:17:09 +07:00
IDEA-182623 Replace with collect swallows comments
This commit is contained in:
+2
-2
@@ -6,8 +6,8 @@ import java.util.List;
|
||||
public class Main {
|
||||
public static String find(List<List<String>> list) {
|
||||
/*
|
||||
Block comment
|
||||
*/
|
||||
Block comment
|
||||
*/
|
||||
return list.stream().flatMap(Collection::stream).filter(string -> string.startsWith("ABC")).findFirst().map(string -> string.substring(3)).orElse("");
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -6,8 +6,8 @@ import java.util.List;
|
||||
public class Main {
|
||||
public static boolean find(List<List<String>> list) {
|
||||
/*
|
||||
Block comment
|
||||
*/
|
||||
Block comment
|
||||
*/
|
||||
return list.stream().flatMap(Collection::stream).filter(string -> string.startsWith("ABC")).findFirst().filter(string -> string.substring(3).equals("xyz")).isPresent();
|
||||
}
|
||||
}
|
||||
+1
@@ -8,6 +8,7 @@ import java.util.Optional;
|
||||
public class Main {
|
||||
private static String test(List<String> list) {
|
||||
Optional<String> found = list.stream().filter(Objects::nonNull).findFirst();
|
||||
// optional!
|
||||
return found.orElse(null);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -4,6 +4,7 @@ import java.util.List;
|
||||
|
||||
public class Main {
|
||||
public int testPrimitiveMap(List<String> data) {
|
||||
return data.stream().filter(str -> str.startsWith("xyz")).mapToInt(String::length).filter(len -> len > 10).findFirst().orElse(0);
|
||||
/*ten*/
|
||||
return data.stream().filter(str -> str.startsWith("xyz")).mapToInt(String::length).filter(len -> len /*bigger*/ > 10).findFirst().orElse(0);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -5,10 +5,10 @@ import java.util.Map;
|
||||
|
||||
public class Main {
|
||||
public void testMap(Map<String, List<String>> map) throws Exception {
|
||||
int bigSize = 0;
|
||||
int bigSize = 0; // initial
|
||||
for(List<String> list : map.valu<caret>es()) {
|
||||
int size = list.size();
|
||||
if(size > 10) {
|
||||
int size = list.size(); // size
|
||||
if(size/*bigger*/ > 10) {
|
||||
bigSize = size*2;
|
||||
break;
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ public class Main {
|
||||
Optional<String> found = Optional.empty();
|
||||
for (String s : li<caret>st) {
|
||||
if (Objects.nonNull(s)) {
|
||||
found = Optional.of(s);
|
||||
found = Optional.of(s); // optional!
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ public class Main {
|
||||
for(String str : dat<caret>a) {
|
||||
if(str.startsWith("xyz")) {
|
||||
int len = str.length();
|
||||
if(len > 10) {
|
||||
if(len /*bigger*/> 10 /*ten*/) {
|
||||
return len;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user