Java8 λ表达式 stream group by max then Option then PlainObject

            ConcurrentMap<Integer, Date> workOrderIdLastestEnterSeaTimeWorkOrderOperationLogDOMap =
                    workOrderOperationLogDOs.stream().collect(
                            Collectors.groupingByConcurrent(WorkOrderOperationLogDO::getWorkOrderId,
                                    Collectors.collectingAndThen(
                                            Collectors.collectingAndThen(
                                                    Collectors.maxBy(Comparator.comparing(WorkOrderOperationLogDO::getCreatedAt)), Optional::get
                                            ), WorkOrderOperationLogDO::getCreatedAt
                                    )
                            )
                    );

 

posted @ 2021-11-29 20:25  任国强  阅读(352)  评论(0编辑  收藏  举报