private static BusinessDomainPo convertToTree(BusinessDomainPo root, List allBusinessDomains) { List children = allBusinessDomains.stream() .filter(businessDomain -> Objects.equals(businessDomain.getParentId(), root.getId())) .map(childBusinessDomain -> convertToTree(childBusinessDomain, allBusinessDomains)) .collect(Collectors.toList()); root.setChildren(children); return root; }

public static List searchTree(List allBusinessDomains, String keyword) { return allBusinessDomains.stream() .filter(businessDomain -> businessDomain.getName().contains(keyword)) .map(businessDomain -> convertToTree(businessDomain, allBusinessDomains)) .collect(Collectors.toList());

private static BusinessDomainPo convertToTreeBusinessDomainPo root ListBusinessDomainPo allBusinessDomains ListBusinessDomainPo children = allBusinessDomainsstream filterbusinessDomain

原文地址: http://www.cveoy.top/t/topic/iXsa 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录