package com.prolog.eis.enums.mcs;

import java.util.Objects;

public enum ShapeEnums {

    NORMAL(1, "正常"),
    FRONT_OVERRUN(2, "前超限"),
    AFTER_OVERRUN(3, "后超限"),
    LEFT_OVERRUN(4, "左超限"),
    RIGHT_OVERRUN(5, "右超限"),
    HEIGHT_OVERRUN(6, "超高");

    private int type;

    private String desc;

    ShapeEnums(int type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getDesc() {
        return desc;
    }

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

    public static String getDesc(int type) {
        for (ShapeEnums value : ShapeEnums.values()) {
            if (value.type == type) {
                return value.desc;
            }
        }
        return null;
    }

    public static int getType(String desc) {
        for (ShapeEnums value : ShapeEnums.values()) {
            if (Objects.equals(desc, value.desc)) {
                return value.type;
            }
        }
        return 0;
    }
}
