mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
StreamToLoop: support Optional unwrap if possible
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
||||
// "Replace Stream API chain with loop" "true"
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
private static String test(List<String> list) {
|
||||
if (list == null) return null;
|
||||
else return list.stream().filter(str -> str.contains("x")).fin<caret>dFirst().orElseGet(() -> null);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(test(Arrays.asList("a", "b", "syz")));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user