入参类型
Map<String, String> userNameToDisplayNameMap,List<Map<String, Object>> resultList, List<Map<String, Object>> mapList
使用stream去掉空数据
mapList = mapList.stream() .filter(sprintData -> sprintData.get("disPlayName") != null) .collect(Collectors.toList());
List<Map<String, Object>> taskList
List<String> elementsToRemove = new ArrayList<>(); elementsToRemove.add("a"); elementsToRemove.add("b"); elementsToRemove.add("c"); //将a,b,c三个元素从集合中剔除 taskList = taskList.stream().filter(a -> !elementsToRemove.contains(a.get("w").toString())).collect(Collectors.toList());
去除重复数据
taskList = taskList.stream().distinct().collect(Collectors.toList());
排序
taskList = taskList.stream().sorted(Comparator.comparing(s -> s.get("q").toString().equals("兔子"))).collect(Collectors.toList());
时间判断
Date date = new Date(); try { Date completedDate = sdf.parse(completedTime); if (date.after(completedDate)) { exceptionResult.append("没有按照时间完成,"); } } catch (ParseException e) { logger.error("时间转化异常:{}", e); }
标签:toList,taskList,stream,elementsToRemove,List,汇总,collect,日常,集合 From: https://www.cnblogs.com/q202105271618/p/17695377.html