JAVA对象合集,根据条件过滤

 

 

ApplyRecord model = RecordService.getById(Apply.getId());
List<Flow> flowList = Service.queryList(model.getCode());
var flow = flowList.stream().filter(item ->model.getApplyStep().equals(item.getFlowId())).collect(Collectors.toList());
// 写lambda表达式时,getXXX获取对象 不会像C#一样自动判断非空。假如改字段为空,会报错。所以用之前,先判断非空:

if(model.getApplyStep() != null ){

  var flow = flowList.stream().filter(item ->model.getApplyStep().equals(item.getPrevFlowId())).collect(Collectors.toList());
}

 

posted @ 2020-07-13 15:22  家伙L  阅读(281)  评论(0编辑  收藏  举报