package com.sf.service.gateway.enums;

import org.springframework.util.StringUtils;

/**
 * 路由活跃状态
 * 
 * @author zoukun
 */
public enum RouteActiveStatus
{
    NOT_ENABLED("0", "探活未开启"),
    OBTAINING("1", "状态获取中"),
    NORMAL("2", "正常"),
    ABNORMAL("3", "异常"),
    ;

    private final String code;
    private final String info;

    RouteActiveStatus(String code, String info)
    {
        this.code = code;
        this.info = info;
    }

    public String getCode()
    {
        return code;
    }

    public String getInfo()
    {
        return info;
    }

    public static RouteActiveStatus getByCode(String code){
        if (StringUtils.hasText(code)) {
            for (RouteActiveStatus value : RouteActiveStatus.values()) {
                if (value.code.equals(code)){
                    return value;
                }
            }
        }
        return null;
    }
}
