Java8 常用方法

  1. 提取类的List的某个字段作为字符串List
    List<String> idList = taskList.stream().map(Task::getTaskId).collect(Collectors.toList());
  2. CompletableFuture无返回值的异步请求
    public Map<String, Object> getWorkflowInfo(String taskId, String employeeCode, Long docId) {
        Map<String, Object> workflowInfo = new HashMap<>(2);
        CompletableFuture<Void> taskDetailInfo = CompletableFuture
                .runAsync(() -> weChatWorkflowService.getTaskDetail(workflowInfo, taskId, employeeCode));
        CompletableFuture<Void> borrowInfo = CompletableFuture
                .runAsync(() -> this.getBorrowInfo(workflowInfo, docId));
    
        try {
            borrowInfo.get();
            taskDetailInfo.get();
        } catch (Exception e) {
            e.printStackTrace();
        }
    
        return workflowInfo;
    }
发布了19 篇原创文章 · 获赞 2 · 访问量 2457

猜你喜欢

转载自blog.csdn.net/Azhuzhu_chaste/article/details/99345467