package com.lantone.security.enums;

import com.lantone.common.constant.KeyedNamed;
import lombok.Setter;

/**
 * @author wangfeng
 * @Description: 菜单类型
 * @date 2018年11月21日 下午2:31:42
 */
public enum MenuTypeEnum implements KeyedNamed {
    MENU(0, "目录"),
    BUTTON(1, "菜单"),
    LABEL(2, "按钮"),
    FUNCTION(3, "功能");

    @Setter
    private int key;

    @Setter
    private String name;

    MenuTypeEnum(int key, String name) {
        this.key = key;
        this.name = name;
    }

    public static MenuTypeEnum getEnum(int key) {
        for (MenuTypeEnum item : MenuTypeEnum.values()) {
            if (item.key == key) {
                return item;
            }
        }
        return null;
    }

    public static String getName(int key) {
        MenuTypeEnum item = getEnum(key);
        return item != null ? item.name : null;
    }

    @Override
    public int getKey() {
        return key;
    }

    @Override
    public String getName() {
        return name;
    }
}

