list.stream()

1、list分组:

Map<String,List<AlarmStatisticalDO>> map = alarmStatisticalDOList.stream().collect(Collectors.groupingBy(a -> a.getAlarmDate()));
for (String alarmDateStr:map.keySet()) {
    List<LibAlarm> libAlarmList = new ArrayList<>();
    List<AlarmStatisticalDO> alarmStatisticalDOS = map.get(alarmDateStr);
   ....
}

2、list排序:

List<LibAlarm> libAlarms = libAlarmList.stream().sorted(Comparator.comparing(LibAlarm::getAlarmCount).reversed()).collect(Collectors.toList());//倒序

 

list.stream()

上一篇:恩欧挨批模拟试题-20


下一篇:监控ansible结果