美文网首页
Java Stream

Java Stream

作者: bigfish1129 | 来源:发表于2018-05-24 15:11 被阅读0次

    1、stream summingInt

    List<Update> allItem = service.listById(a, b).stream()
                .filter(t -> t.getId() != null && t.getId() > 0)
                .collect(groupingBy(DO::getGId,
                    summingInt(DO::getNumber)))
                .entrySet().stream().map(Detail -> {
                    Update DTO = new DTO();
                    DTO.setCode("A");
                    DTO.setNum(Detail.getValue());
                    DTO.setGId(Long.valueOf(Detail.getKey()));
                    DTO.setSId(Joiner.on("_").join(Id, Detail.getKey()));
                    return DTO;
                }).collect(Collectors.toList());
    

    相关文章

      网友评论

          本文标题:Java Stream

          本文链接:https://www.haomeiwen.com/subject/pzrsjftx.html