上代码

 

 

//获取list对象 list属性 并进行去重
List<String> collect = users.stream().map(e -> e.getUserName()).distinct().collect(Collectors.toList());

 

Java 8 List<对象> 获取其中属性 返回List<String> 并且去重

 

 

 单独获取List对象某个属性操作

List<String> collect = users.stream().map(e -> e.getUserName()).collect(Collectors.toList());

单独去重操作

List<String> distinctElements = list.stream().distinct().collect(Collectors.toList()); 

业务思路: 

1.一对多中,子集有多个不同的状态码,父集需要根据子集状态来调整整体的订单状态

if (collect.size() == 1){
   batchOrder1.setStatus(collect.get(0));
   batchOrderService.updateById(batchOrder1);
}

控台测试

 Java 8 List<对象> 获取其中属性 返回List<String> 并且去重

 

相关文章:

  • 2021-11-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-12
  • 2021-12-03
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-11
  • 2022-01-07
  • 2022-01-22
相关资源
相似解决方案