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 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); } }