package com.qmth.themis.business.enums;

import java.util.Objects;

/**
 * @Description: 异常类型 enum
 * @Param:
 * @return:
 * @Author: wangliang
 * @Date: 2020/7/29
 */
public enum ExceptionEnum {

    NET_TIME_OUT("网络超时"),

    MACHING_STOP("机器硬件故障、死机"),

    NET_TIME_BREAK("网络断开"),

    SOFTWARE_STOP("软件故障"),

    POWER_CUT("停电"),

    OTHER("其它"),

    EXIT("退出");

    private String code;

    private ExceptionEnum(String code) {
        this.code = code;
    }

    public String getCode() {
        return code;
    }

    /**
     * 状态转换 toName
     *
     * @param code
     * @return
     */
    public static String convertToName(String code) {
        for (ExceptionEnum e : ExceptionEnum.values()) {
            if (Objects.equals(e.getCode(), code)) {
                return e.name();
            }
        }
        return null;
    }
}
