java8新特性构建树结构工具类

public class CreateOrgTreeUtil {
public static List<OrgDTO> CreateTree(int parentId, List<OrgDTO> treeEntityList) {
return treeEntityList.stream()
.filter(treeEntity -> treeEntity.getNmParentid()==parentId)
.peek(treeEntity -> treeEntity.setChildren(CreateTree(treeEntity.getNmId(), treeEntityList)))
.collect(Collectors.toList());
}
}
上一篇:Java8 Lambda表达式、函数式接口和方法引用


下一篇:史上最全Java8日期时间工具类