All Downloads are FREE. Search and download functionalities are using the official Maven repository.

wang.ramboll.extend.request.limit.enums.RequestFrequencyLimitMode Maven / Gradle / Ivy

There is a newer version: 1.0.4-RC.1
Show newest version
package wang.ramboll.extend.request.limit.enums;

/**
 * 访问请求频率限制模式
 * @author WangRuibo
 */
public enum RequestFrequencyLimitMode {
    /**
     * RequestURI参与拦截条件
     */
    URI(1),
    /**
     * RequestBody注解参数参与拦截条件
     */
    REQUEST_BODY(2),
    /**
     * RequestParam注解参数参与拦截条件
     */
    REQUEST_PARAM(3),
    /**
     * RequestHeader注解参数参与拦截条件
     */
    REQUEST_HEADER(4),
    /**
     * RequestAttribute注解参数参与拦截条件
     */
    REQUEST_ATTRIBUTE(5),


    ;


    private int mode ;

    RequestFrequencyLimitMode(int mode) {
        this.mode = mode;
    }

    public int getMode() {
        return mode;
    }

    /**
     * 从数组中判断是否包含某一模式
     * @param target 目标模式
     * @param modes 模式数组
     * @return
     */
    public static boolean contains(RequestFrequencyLimitMode target,RequestFrequencyLimitMode[] modes){
        for(RequestFrequencyLimitMode m : modes){
            if(target.mode==m.mode) return true ;
        }
        return false ;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy