首页 > 编程语言 >java8-笔记

java8-笔记

时间:2022-10-28 09:24:50浏览次数:35  
标签:stream Collectors collect 笔记 item new java8 wardDurationCall

获取某个字段的值
List<Integer> num = modelList.stream().map(model::getID).collect(Collectors.toList());

根据某个字段去重再获取某个字段的值。
List<CallBillModel> studentList = CBModels.stream()
.collect(Collectors.collectingAndThen(
Collectors.toCollection(
() -> new TreeSet<>(Comparator.comparing(CallBillModel::getCallUuid))),
ArrayList::new));

去重,取最后一条
hisLabReportModelList = new ArrayList<>(hisLabReportModelList.stream()
.collect(Collectors.toMap(HisLabReportModel::getCheckNo, Function.identity(), (key1, key2) -> key2))
.values());

根据某个字段 分组构造数据、统计数量,然后排序
List<WardDurationCall> durationNameList = wardCallStatistics.getDurations().stream()
.collect(Collectors.groupingBy(
item -> StringHelper.format("{0}_{1}", item.getDurationName(), item.getDurationOrder()),
Collectors.counting()))
.entrySet().stream().map(item ->
{
WardDurationCall wardDurationCall = new WardDurationCall();
String[] keyData = item.getKey().split("_");
wardDurationCall.setDurationName(keyData[0]);
wardDurationCall.setCount(item.getValue());
wardDurationCall.setDurationOrder(Integer.parseInt(keyData[1]));
return wardDurationCall;
}).sorted(Comparator.comparing(WardDurationCall::getDurationOrder))
.collect(Collectors.toList());


标签:stream,Collectors,collect,笔记,item,new,java8,wardDurationCall
From: https://www.cnblogs.com/xiaojietian/p/16834708.html

相关文章

  • FX3U+BCNET-FX实操笔记
                 ......
  • 关于华硕UX31E笔记本可识别U盘uefi启动却无法识别本地SSD盘uefi信息的解决办法
    问题描述:该笔记本bios明确有uefienable选项,证明一定是支持uefi启动的,而且只有单SSD盘也全盘格成了GPT模式,当ESP已经修复了引导信息,重启后还是reboot...提示,好似根本没有......
  • AQS相关笔记
    电脑修了快20填了,还没修好,我服了。。。也没有好记笔记和学习的地方,所以干脆在这里记笔记好了。AQSAQS具备特性:1.阻塞等待队列2.共享/独占3.公平/非公平4.可重入......
  • html-常用样式或脚本的学习笔记
    (一)CSS样式相关1.禁止拖动图片img{-webkit-user-drag:none;}2.去除select默认下拉图标.select{appearance:none;-webkit-appearance:none;......
  • docker学习笔记
    @目录前言1docker简介1.1是什么1.1.1为什么会有docker出现1.1.2docker理念1.2容器与虚拟机比较1.2.1容器发展简史1.2.2传统虚拟机技术1.2.3容器虚拟化技术1.2.4......
  • Java开发笔记之EasyExcel实现自定义合并策略
    0x00概述本文转载,原文原本是想学习使用Apache的POI的,但是无意中看到Alibaba的开源工具EastExcel,据说比POI更加快速高效,关键是使用起来也简单。官网地址为:https://aliba......
  • 【学习笔记】Mybatis配置优化
    Mybatis配置优化1.核心配置文件结构核心配置文件:mybatis-config.xml官方建议起这个名字,但我们可以随意起名configuration(配置)properties(属性)settings(设置)ty......
  • Basil: A Fast and Byzantine-Resilient Approach for Decentralized Training 阅读笔
    Basil:AFastandByzantine-ResilientApproachforDecentralizedTraining阅读笔记ProblemStatementDecentralizedSystemModel所有训练数据样本存储在分布式节......
  • STM32MP157 LINUX学习笔记01
    开发板IP:192.168.5.9配置命令ifconfigeth0192.168.5.9windowsIP:192.168.5.10ubuntuIP: 192.168.5.11首先确保三者互ping通过 通过这个博客学习如何配置ubuntu......
  • vue-element-admin框架学习笔记
    0背景vue-element-admin是一个已高度完成的系统原型,它基于vue框架和elementUI组件库。它使用最新的前端技术栈,内置i18n国际化解决方案、动态路由、权限验证。它可以帮助......