package com.ningdatech.carapi.common.constant;

import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/**
 * 告警等级
 *
 * @author PoffyZhang
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "AlarmLevelEnum", description = "告警等级-枚举")
public enum AlarmLevelEnum {
    /**
     * 主动抓拍事件
     */
    EARLY_WARNING(1, "预警"),
    GIVE_ALARM(2, "报警");

    private Integer code;
    private String desc;


    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public static String getDescByCode(int code) {
        if(Objects.isNull(code)){
            return StringUtils.EMPTY;
        }
        for (AlarmLevelEnum t : AlarmLevelEnum.values()) {
            if (code == t.getCode()) {
                return t.desc;
            }
        }
        return StringUtils.EMPTY;
    }

    public boolean eq(String val) {
        return this.name().equals(val);
    }

}
