java8 流stream开发说明;Stream流 是 Java 8 引入的一种新特性,用于以声明式的方式处理数据集合。它提供了高效、简洁的操作方式,支持对集合、数组等数据源进行复杂的聚合操作。

List<Model> modelList = list.stream().filter(e -> !e.getId().equals(model.getId())).collect(Collectors.toList());

        if(CollectionUtil.isNotEmpty(modelList)){
            List<Model> models = modelList.stream().filter(e -> e.getKey().equals(key)).collect(Collectors.toList());
            if(CollectionUtil.isNotEmpty(models)){
                return R.fail("模型KEY已存在");
            }
        }

排序

list.stream().sorted(Comparator.comparing(HistoricTaskInstance::getEndTime, Comparator.nullsFirst(Date::compareTo))).collect(Collectors.toList());

排序

List<Comment> taskComments = taskService.getTaskComments(historicTaskInstance.getId());

        if(CollectionUtil.isNotEmpty(taskComments)){
            actHistoryInfoVo.setCommentId(taskComments.get(0).getId());
            String message = taskComments.stream()
                .map(Comment::getFullMessage).collect(Collectors.joining("。"));
            if (StringUtils.isNotBlank(message)) {
                actHistoryInfoVo.setComment(message);
            }
        }

翻译

    if (CollUtil.isNotEmpty(actHistoryInfoVoList)) {
        List<Long> assigneeList = actHistoryInfoVoList.stream().map(e -> Long.valueOf(e.getAssignee())).collect(Collectors.toList());
        if (CollUtil.isNotEmpty(assigneeList)) {
            List<SysUser> sysUsers = iUserService.selectListUserByIds(assigneeList);
            actHistoryInfoVoList.forEach(e -> {
                sysUsers.stream().filter(u -> u.getUserId().toString().equals(e.getAssignee())).findFirst().ifPresent(u -> {
                    e.setNickName(u.getNickName());
                });
            });
        }
    }