场景:
由于对应字段在数据库中是0,1标志位存的,需要在展示时变成是,否的中文字
不废话,直接上代码:
List<MItemDataExcelPojo> poJoList = new ArrayList<>(list.size() + 1); poJoList = JSON.parseArray(JSON.toJSONString(list), MItemDataExcelPojo.class); poJoList = poJoList.stream().filter(x -> !ToolsUtil.isEmpty(x.getIsBeyond()) && !ToolsUtil.isEmpty(x.getIsFinish())).map(x -> { if ("0".equals(x.getIsBeyond())){ x.setIsBeyond("否"); }else{ x.setIsBeyond("是"); } if ("0".equals(x.getIsFinish())){ x.setIsFinish("否"); }else{ x.setIsFinish("是"); } return x; }).collect(Collectors.toList()); return poJoList;
适用于对象的单个属性和多个属性值的替换