package com.sf.service.gateway.enums;

import org.springframework.util.StringUtils;

/**
 * 网关服务模式
 * 
 * @author zoukun
 */
public enum GatewayServiceModel
{
    NORMAL("NORMAL", "普通模式"),
    ROUTE("ROUTE", "路由模式"),
    ;

    private final String code;
    private final String info;

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

    public String getCode()
    {
        return code;
    }

    public String getInfo()
    {
        return info;
    }

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