java 다중 메뉴 구현 (귀속)
질의 메뉴 트리:
public List
/**
*
* @param id id
* @param allMenu
* @return ,
*/
private List> getChild(String id,List> allMenu){
//
List> childList = new ArrayList>();
for (Map nav : allMenu) {
// , id id
// : 。
String parentId = String.valueOf(nav.get("parent_id"));
if(id.equals(parentId)){
childList.add(nav);
}
}
//
for (Map nav : childList) {
String tempId = String.valueOf(nav.get("category_id"));
//nav.setChildren(,getChild(tempId, allMenu));
nav.put("child", getChild(tempId, allMenu));
}
//Collections.sort(childList,order());//
// , List( )
if(childList.size() == 0){
return new ArrayList>();
}
return childList;
}