Stream流式处理常见使用
list 遍历前判空
语义:list如果不为空,stream流式处理,为空直接返回一个空list
ArrayList <TestDTO> list = new List<>();
Optional.ofNullable(list).orElse(Collections.emptyList()).stream().map().collect(Collectors.toList());
stream()可以接的方法(前面默认加了上面的判空)
filter()
语义 :作为list的过滤条件用,filter可以放在前面也可以放在后面,代表过滤filter()之前的list(最重