Java 8: Converting Map<Long, List<Long>> to Map<Long, Long[]> [duplicate]

原创
2020/08/05 15:22
阅读数 78
 
Map<String, Map<String, List<String>>> testMap = foos.stream().collect(Collectors.groupingBy(e -> e.getAreaName(),
        Collectors.groupingBy(e -> e.getObjectName(), Collectors.collectingAndThen(Collectors.toList(),
                e -> e.stream().map(f -> f.getLineName())))));
Map<String, List<String>> parameters;

Map<String, String[]> collect = parameters.entrySet().stream()
                .collect(Collectors.toMap(entry-> entry.getKey(),entry -> entry.getValue().toArray()));
Map<Object, Map<Object, List<Foo>>> testMap = ventures.stream().collect(Collectors.groupingBy(e -> e.getAreaName(),
        Collectors.groupingBy(e -> e.getObjectName(), Collectors.toList())));
Map<String, String[]> collect = 
    parameters.entrySet()
              .stream()
              .collect(Collectors.toMap(Map.Entry::getKey,
                                        entry -> entry.getValue().toArray(new String[0])));
Map<Long, List<Long>> maps = css.parallelStream().collect(Collectors.groupingBy(CompanyInfoEntity::getDid, Collectors.mapping(CompanyInfoEntity::getId, Collectors.toList())));

 

Map<Object, Map<Object, List<Foo>>> testMap = ventures.stream().collect(Collectors.groupingBy(e -> e.getAreaName(),
        Collectors.groupingBy(e -> e.getObjectName(), Collectors.toList())));
Map<String, Map<String, List<String>>> testMap = 
    foos.stream()
        .collect(Collectors.groupingBy(Foo::getAreaName,
                                       Collectors.groupingBy(Foo::getObjectName,
                                                             Collectors.mapping(Foo::getLineName,
                                                                                Collectors.toList()))));
展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部