利用stream流将一个对象集合转换成另一个对象集合!

利用stream流将一个对象集合转换成另一个对象集合!

  List<BVideoHistory> bVideoHistoryList=new ArrayList<>();

        List<BVideoRank> bVideoRankList = bilibiliRank.bVideoRankArraylist(0);
        if (CollectionUtils.isNotEmpty(bVideoRankList)){ 
            bVideoHistoryList=bVideoRankList.stream().map(bVideoRank->{ 
                BVideoHistory bVideoHistory=new BVideoHistory();
                bVideoHistory.setBvNumber(bVideoRank.getBvNumber());
                bVideoHistory.setBvTitle(bVideoRank.getBvTitle());
                bVideoHistory.setBvUp(bVideoRank.getBvUp());
                bVideoHistory.setBvUpuuid(bVideoRank.getBvUpuuid());
                return bVideoHistory;
            }).collect(Collectors.toList());
        }
    原文作者:唥雨凊
    原文地址: https://blog.csdn.net/weixin_44777669/article/details/108579020
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞