package com.red.circle.console.infra.database.rds.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.red.circle.framework.mybatis.enums.IEnum;

/**
 * <p>
 * 菜单类型枚举.
 * </p>
 *
 * @author pengliang
 */
public enum MenuTypeEnum implements IEnum {

  /**
   * 目录
   */
  CATALOG(1),
  /**
   * 菜单
   */
  MENU(2),
  /**
   * 按钮
   */
  BUTTON(3);

  @EnumValue
  private final int value;

  MenuTypeEnum(final int value) {
    this.value = value;
  }

  @JsonCreator
  public static MenuTypeEnum toEnum(int value) {
    for (MenuTypeEnum menuTypeEnum : MenuTypeEnum.values()) {
      if (menuTypeEnum.getValue() == value) {
        return menuTypeEnum;
      }
    }
    throw new UnknownEnumException("Error: Invalid MenuTypeEnum type value: " + value);
  }

  @Override
  @JsonValue
  public int getValue() {
    return this.value;
  }
}
