Commit 3c3a68fd by 杨林龙

1.9.0 仲利车辆列表增加最后定位时间字段-- 优化空指针判断逻辑

1 parent 01b3cdc5
...@@ -3,7 +3,10 @@ package cn.com.glsx.test; ...@@ -3,7 +3,10 @@ package cn.com.glsx.test;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -24,19 +27,14 @@ public class MainTest { ...@@ -24,19 +27,14 @@ public class MainTest {
// Creating a list of Even Numbers // Creating a list of Even Numbers
List<Integer> EvenNumbers = Arrays.asList(2, 4, 6, 8); List<Integer> EvenNumbers = Arrays.asList(2, 4, 6, 8);
List<List<Integer>> listOfListofInts = List<List<Integer>> listOfListofInts = Arrays.asList(PrimeNumbers, OddNumbers, EvenNumbers);
Arrays.asList(PrimeNumbers, OddNumbers, EvenNumbers);
System.out.println("The Structure before flattening is : " + System.out.println("The Structure before flattening is : " + listOfListofInts);
listOfListofInts);
// Using flatMap for transformating and flattening. // Using flatMap for transformating and flattening.
List<Integer> listofInts = listOfListofInts.stream() List<Integer> listofInts = listOfListofInts.stream().flatMap(Collection::stream).collect(Collectors.toList());
.flatMap(list -> list.stream()) Optional.of(listofInts).ifPresent(System.out::println);
.collect(Collectors.toList()); // System.out.println("The Structure after flattening is : " + listofInts);
System.out.println("The Structure after flattening is : " +
listofInts);
} }
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!