SendEventEnum.java 944 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package com.fjhx.enums;
  2. import cn.hutool.core.util.ObjectUtil;
  3. import lombok.Getter;
  4. import java.util.HashMap;
  5. @Getter
  6. public enum SendEventEnum {
  7. /**
  8. * 收到新邮件
  9. */
  10. MESSAGE_NEW("messageNew"),
  11. /**
  12. * 删除邮件
  13. */
  14. MESSAGE_DELETED("messageDeleted"),
  15. /**
  16. * Email Flag被改变
  17. */
  18. MESSAGE_UPDATED("messageUpdated"),
  19. /**
  20. * 未知事件
  21. */
  22. UNKNOWN_EVENT("unknownEvent");
  23. private final String type;
  24. private static final HashMap<String, SendEventEnum> map = new HashMap<>();
  25. SendEventEnum(String type) {
  26. this.type = type;
  27. }
  28. static {
  29. for (SendEventEnum value : SendEventEnum.values()) {
  30. map.put(value.getType(), value);
  31. }
  32. }
  33. /**
  34. * 根据type获取枚举
  35. */
  36. public static SendEventEnum get(String type) {
  37. return ObjectUtil.defaultIfNull(map.get(type), UNKNOWN_EVENT);
  38. }
  39. }