asTree() 추가

master
mjkhan21 6 months ago
parent bfc2cd515b
commit 2f3339c263

@ -23,7 +23,7 @@ public class RequestHandlerReader extends AbstractComponent {
* @param requestHandlerMappings
* @return {"name", "url", "parentID"}
*/
public List<DataObject> read(RequestMappingHandlerMapping requestHandlerMappings) {
public Hierarchy<DataObject> asTree(RequestMappingHandlerMapping requestHandlerMappings) {
Map<RequestMappingInfo, HandlerMethod> handlers = requestHandlerMappings.getHandlerMethods();
ArrayList<DataObject> nameURLs = new ArrayList<>();
@ -50,7 +50,7 @@ public class RequestHandlerReader extends AbstractComponent {
nameURLs.add(menuItem(null, parentID));
});
Hierarchy<DataObject> tree = new HierarchyBuilder<DataObject>()
return new HierarchyBuilder<DataObject>()
.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<DataObject> read(RequestMappingHandlerMapping requestHandlerMappings) {
Hierarchy<DataObject> tree = asTree(requestHandlerMappings);
List<DataObject> top = tree.topElements();
Collections.sort(top, (u0, u1) -> u0.string("url").compareTo(u1.string("url")));
return top;

Loading…
Cancel
Save