package cn.cecep.talroad.enums;

import java.util.Arrays;

public enum InvalidStateEnum {

    C("C","C"),
    M("M","M"),
    D("D","D"),
    MD("MD","MD"),
    K("K","K"),
    P("P","P"),
    VGD("VGD","VGD"),
    TD("TD","TD"),
    ST("ST","ST"),
    SD("SD","SD"),
    B("B","B"),
    STA("STA","STA"),
    F("F","F"),
    FA("FA","FA");

    private String code;
    private String name;

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

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

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

}
