12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- package com.fjhx.enums;
- import cn.hutool.core.util.ObjectUtil;
- import lombok.Getter;
- import java.util.HashMap;
- @Getter
- public enum SendEventEnum {
- /**
- * 收到新邮件
- */
- MESSAGE_NEW("messageNew"),
- /**
- * 删除邮件
- */
- MESSAGE_DELETED("messageDeleted"),
- /**
- * Email Flag被改变
- */
- MESSAGE_UPDATED("messageUpdated"),
- /**
- * 未知事件
- */
- UNKNOWN_EVENT("unknownEvent");
- private final String type;
- private static final HashMap<String, SendEventEnum> map = new HashMap<>();
- SendEventEnum(String type) {
- this.type = type;
- }
- static {
- for (SendEventEnum value : SendEventEnum.values()) {
- map.put(value.getType(), value);
- }
- }
- /**
- * 根据type获取枚举
- */
- public static SendEventEnum get(String type) {
- return ObjectUtil.defaultIfNull(map.get(type), UNKNOWN_EVENT);
- }
- }
|