mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-26 19:06:24 +07:00
StreamToLoop: support Optional unwrap if possible
This commit is contained in:
+2
-5
@@ -2,20 +2,17 @@
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class Main {
|
||||
private static String test(List<String> list) {
|
||||
if (list == null) return null;
|
||||
else {
|
||||
Optional<String> found = Optional.empty();
|
||||
for (String str : list) {
|
||||
if (str.contains("x")) {
|
||||
found = Optional.of(str);
|
||||
break;
|
||||
return str;
|
||||
}
|
||||
}
|
||||
return found.orElse(null);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user