public class RouteRule extends Object
key1 = value11,value12 & key2 = value21 & key2 != value22 => key3 = value3 & key4 = value41,vlaue42 & key5 !=value51
。
=>之前的称为When条件,是KV对;之后是Then条件,是KV对。KV的Value可以有多个值。| 限定符和类型 | 类和说明 |
|---|---|
static class |
RouteRule.MatchPair |
public static Map<String,RouteRule.MatchPair> parseRule(String rule) throws ParseException
ParseExceptionpublic static RouteRule parse(Route route) throws ParseException
ParseException - RouteRule字符串格式不对了。以下输入的情况,RouteRule都是非法的。
null。
public static RouteRule parse(String whenRule, String thenRule) throws ParseException
ParseExceptionpublic static RouteRule parse(String rule) throws ParseException
ParseExceptionpublic static RouteRule parseQuitely(Route route)
RuntimeException - 解析出错时,Wrap了parse(String)方法的抛出的ParseException的异常。parse(String)public static RouteRule createFromNameAndValueListString(Map<String,String> whenParams, Map<String,String> notWhenParams, Map<String,String> thenParams, Map<String,String> notThenParams)
public static RouteRule createFromCondition(Map<String,RouteRule.MatchPair> whenCondition, Map<String,RouteRule.MatchPair> thenCondition)
public static RouteRule copyWithRemove(RouteRule copy, Set<String> whenParams, Set<String> thenParams)
public static RouteRule copyWithReplace(RouteRule copy, Map<String,RouteRule.MatchPair> whenCondition, Map<String,RouteRule.MatchPair> thenCondition)
copy - 替换的BasewhenCondition - 要替换的whenCondition,如果Base没有项目,则直接插入。thenCondition - 要替换的thenCondition,如果Base没有项目,则直接插入。public static boolean matchCondition(Map<String,String> sample, Map<String,RouteRule.MatchPair> condition)
如果样本的KV中,存在Key有对应的MatchPair,且Value不通过MatchPair里,返回false;
否则返回true。
public static void contidionToString(StringBuilder sb, Map<String,RouteRule.MatchPair> condition)
public Map<String,RouteRule.MatchPair> getWhenCondition()
public Map<String,RouteRule.MatchPair> getThenCondition()
public String getWhenConditionString()
public String getThenConditionString()
Copyright © 2011–2017 Alibaba. All rights reserved.