ButtonNameEnum.java 980 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package com.fjhx.enums;
  2. import lombok.Getter;
  3. import java.util.HashMap;
  4. /**
  5. * 按钮名称
  6. */
  7. @Getter
  8. public enum ButtonNameEnum {
  9. // 审核
  10. ADOPT(1, "通过"),
  11. FAIL(2, "不通过"),
  12. // 审批
  13. AGREE(3, "同意"),
  14. REJECT(4, "驳回"),
  15. // 办理
  16. complete(5, "完成");
  17. private final Integer type;
  18. private final String name;
  19. private static final HashMap<Integer, ButtonNameEnum> map = new HashMap<>();
  20. ButtonNameEnum(Integer type, String name) {
  21. this.type = type;
  22. this.name = name;
  23. }
  24. static {
  25. for (ButtonNameEnum value : ButtonNameEnum.values()) {
  26. map.put(value.getType(), value);
  27. }
  28. }
  29. /**
  30. * 根据type获取枚举
  31. */
  32. public static ButtonNameEnum get(Integer type) {
  33. return map.get(type);
  34. }
  35. /**
  36. * 根据type值获取枚举
  37. */
  38. public static String getName(Integer type) {
  39. return map.get(type).getName();
  40. }
  41. }