首页 > 编程知识 正文

groupby的用法及原理详解,集合名词staff用法

时间:2023-05-04 04:03:09 阅读:126474 作者:4286

项目有常见的数据包需求。 这里用产品的照片说明。

返回到前端的数据格式可能是这样的

数据' : { ' title ' :我是产品的标题。 请无视。 ',' images':['https://xxx.jpg ',' https://yyy.jpg'] ','视频'。

[ {'type':1,' path':'https://xxx.jpg'},/图像1 {'type':1,' path':'https://yyy.jpg'},/path ' https://YY.jpg ' ] ' path ' : ' https://XXX.MP4 ' }//视频]中,从上面的回复格式可以看出,获得了MapInteger,ListString这样的数据格式

//数据源listproductresourcesresourceslist=new ArrayList (; //图1 productresourcesproductresources=new product resources (; 产品资源. set path (图像一遍); 产品资源. settype (1; 资源列表. add (产品资源; }//图2 productresourcesproductresources=new product resources (; 产品资源. set path (图像两遍); 产品资源. settype (1; 资源列表. add (产品资源; }//视频1 productresourcesproductresources=new product resources (; 产品资源. set path ('视频1路径); 产品资源. settype (2; 资源列表. add (产品资源; //数据if(collectionutils.isnotempty ) resourceslist ) { MapInteger,listproductresourcescollect=resources list.str ist ListProductResources似乎与MapInteger、ListString略有差距。

一种方法是遍历得到的MapInteger,ListProductResources数据,将ProductResources的path设置为List集合,最终得到MapInteger,ListString

最简洁的写法是地图整合器, liststringcollect=resources list.stream ().collect ) collectors.groupingby ) product resources 336033333333 colllectors.mor Collectors.toList ()进一步获取目标MapInteger、ListString数据格式。 然后,collect.get(1)得到图像,collect.get(1)得到视频就可以了。

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。