package com.ningdatech.carapi.analysis.entity.enumeration;

import lombok.Getter;

import java.util.Arrays;

/**
 * <p>
 * DangerLevel
 * </p>
 *
 * @author WendyYang
 * @since 17:18 2022/10/25
 */
@Getter
public enum DangerLevel {
    /**
     * 预警
     */
    RED(1, "红色预警"),
    ORANGE(2, "橙色预警"),
    YELLOW(3, "黄色预警"),
    BLUE(4, "蓝色预警");

    private final Integer code;
    private final String name;

    DangerLevel(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public static DangerLevel getByCode(Integer code) {
        return Arrays.stream(values())
                .filter(w -> w.getCode().equals(code))
                .findFirst()
                .orElseThrow(() -> new IllegalArgumentException("预警级别编码无效"));
    }

}
