package com.sf.service.gateway.enums;

import org.springframework.util.StringUtils;

/**
 * 网关路由类型
 * 
 * @author zoukun
 */
public enum GatewayRouteType
{
    WEIGHT_ROUTE("WEIGHT_ROUTE", "权重路由策略"),
    HEADER_ROUTE("HEADER_ROUTE", "请求头路由策略"),
    ;

    private final String code;
    private final String info;

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

    public String getCode()
    {
        return code;
    }

    public String getInfo()
    {
        return info;
    }

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