diff --git a/src/main/java/cokr/xit/foundation/web/RequestHandlerReader.java b/src/main/java/cokr/xit/foundation/web/RequestHandlerReader.java index f0eccad..4b697f1 100644 --- a/src/main/java/cokr/xit/foundation/web/RequestHandlerReader.java +++ b/src/main/java/cokr/xit/foundation/web/RequestHandlerReader.java @@ -23,7 +23,7 @@ public class RequestHandlerReader extends AbstractComponent { * @param requestHandlerMappings 요청 매핑 * @return {"name", "url", "parentID"} 정보 목록 */ - public List read(RequestMappingHandlerMapping requestHandlerMappings) { + public Hierarchy asTree(RequestMappingHandlerMapping requestHandlerMappings) { Map handlers = requestHandlerMappings.getHandlerMethods(); ArrayList nameURLs = new ArrayList<>(); @@ -50,7 +50,7 @@ public class RequestHandlerReader extends AbstractComponent { nameURLs.add(menuItem(null, parentID)); }); - Hierarchy tree = new HierarchyBuilder() + return new HierarchyBuilder() .getID(row -> row.string("url")) .getParentID(row -> row.string("parentID")) .atTop(row -> "/".equals(row.string("parentID"))) @@ -62,7 +62,14 @@ public class RequestHandlerReader extends AbstractComponent { }) .setElements(nameURLs) .build(); + } + /**컨트롤러에 명시된 {@code @RequestMapping} 어노테이션을 읽어들여, {"name", "url", "parentID"} 정보를 추출하여 목록으로 반환한다. + * @param requestHandlerMappings 요청 매핑 + * @return {"name", "url", "parentID"} 정보 목록 + */ + public List read(RequestMappingHandlerMapping requestHandlerMappings) { + Hierarchy tree = asTree(requestHandlerMappings); List top = tree.topElements(); Collections.sort(top, (u0, u1) -> u0.string("url").compareTo(u1.string("url"))); return top;