java中stream流转换
实体类List转实体类map
Map<String, List<MerGameVersionVo>> categoryNameMap = merGameVos.stream().collect(Collectors.groupingBy(MerGameVersionVo::getCategoryName));
Map<String, MerGameVersionVo> nameMap = merGameVos.stream().collect(Collectors.toMap(MerGameVersionVo::getName, t -> t, (o1, o2) -> o1));
实体类list转复合主键的map
List<SkillPrice> skillPrices = skillPriceMapper.selectSkillPriceList();
Map<String, SkillPrice> stringSkillPriceMap= skillPrices.stream().collect(Collectors.toMap(t->t.getSkill().toString()+":"+t.getSkillLevel().toString(),t -> t,(o1,o2) -> o1));
实体类list集合实现倒叙
infos = infos.stream().sorted((e1, e2) -> e2.getRecharge_money().compareTo(e1.getRecharge_money())).collect(Collectors.toList());
6583

被折叠的 条评论
为什么被折叠?



