java1.8 stream常用的方法记录
1.从List<Map<String,String>>中取map的一个值,并用逗号拼接
List<Map<String,String>>sendZhusongIdList=dispatchDO.getSendZhusongIdList();
StringsendZhusongName=sendZhusongIdList.stream().map(x->x.get("text")).collect(Collectors.joining(","));
System.err.println("sendZhusongName:"+sendZhusongName);
2.过滤后取出需要的值拼接成字符串
List<OpinionDO>opinionList=opinionService.listByMainId(map.get("ID").toString());StringdeptLeaderName=opinionList.stream().filter(x->"divisionHead".equals(x.getFieldKey()))map(x->x.getCreateUserName().toString()).collect(Collectors.joining(","));
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。