package cn.cecep.talroad.enums;

import java.util.Arrays;

/**
 * @Auther: cjh
 * @Date: 2023-03-30 16:24
 * @Class: ReleaseStatusEnum
 * @Deseription:
 * @Version V1.0
 */
public enum ReleaseStatusEnum {


    NORMAL("1","正常放散"),
    ERROR("2","异常放散"),
    UNREAL("3","未放散"),
    OFFLINE("4","离线"),
    YC("5","异常");


    private String code;
    private String name;

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

    /**
     * 根据编码获取名称
     * @param code
     * @return
     */
    public static String getNameByCode(String code){
        return Arrays.stream(values()).filter(v -> v.getCode().equalsIgnoreCase(code)).findAny().get().getName();
    }

    /**
     * 根据编码获取枚举类型
     * @param code
     * @return
     */
    public ReleaseStatusEnum getEnumByCode(String code){
        return Arrays.stream(values()).filter(v -> v.getCode().equalsIgnoreCase(code)).findAny().get();
    }


    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
