|
@@ -0,0 +1,18 @@
|
|
|
|
+package com.weavi.ahh_v2.utils;
|
|
|
|
+
|
|
|
|
+import java.util.Collections;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Optional;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @auther jiangzuole
|
|
|
|
+ * @date 2019-05-28
|
|
|
|
+ * @time 10:39
|
|
|
|
+ */
|
|
|
|
+public class Optional2List {
|
|
|
|
+ public static <T> List<T> toList(Optional<T> option) {
|
|
|
|
+ return option.
|
|
|
|
+ map(Collections::singletonList).
|
|
|
|
+ orElse(Collections.emptyList());
|
|
|
|
+ }
|
|
|
|
+}
|