Test
定义枚举类型,使菜单对应唯一ID、文字,同时包含父菜单和子菜单,定义方法将所有枚举成员转换为菜单树的形式。拓展菜单只需要修改枚举类型即可。
public enum TreeMenu_e{
MENU0("菜单0",null),
MENU0_SUB0("子菜单0",MENU0),MENU0_SUB1("子菜单1",MENU0),
MENU1("菜单0",null),
MENU1_SUB0("",MENU1),MENU1_SUB0("",MENU1)
private TreeMenu_e parent=null;
private String text;
public TreeMenu_e(String text,TreeMenu_e parent){
this.parent=parent;
this.text=text;
}
public int getId(){...;}
public String getText(){...;}
public TreeMenu_e getParent(){...;}
}