@Test public void test_范围() { String param = "id,1_number,0_1024|1m_1g"; AdvancedParameter result = AdvancedParameterParser.getAdvancedParamByParamTokenNew(param, false); testResult(result, AtomIncreaseType.NUMBER, new AdvancedParameter.Range[] { getRange(0, 1024), getRange(1 * 1000000, 1 * 1000000000) }, 1); param = "id,0_1024|1m_1g"; result = AdvancedParameterParser.getAdvancedParamByParamTokenNew(param, false); testResult(result, AtomIncreaseType.NUMBER, new AdvancedParameter.Range[] { getRange(0, 1024), getRange(1 * 1000000, 1 * 1000000000) }, 1); }
public static AdvancedParameter getAdvancedParamByParamTokenNew(String paramToken, boolean completeConfig) { String key; boolean[] needAppear = new boolean[1]; AtomIncreaseType atomicIncreateType = null; Comparable<?> atomicIncreateValue = null; Range[] rangeObjectArray = null; Integer cumulativeTimes = null; String[] paramTokens = TStringUtil.split(paramToken, PARAM_SEGMENT_SPLITOR); switch (paramTokens.length) { case 1: if (completeConfig) { throw new IllegalArgumentException("规则必须配置完全，格式如下:#id,1_number,1024#"); } key = parseKeyPart(paramTokens[0], needAppear); break; case 2: key = parseKeyPart(paramTokens[0], needAppear); atomicIncreateType = AtomIncreaseType.NUMBER; atomicIncreateValue = 1; try { rangeObjectArray = parseRangeArray(paramTokens[1]); cumulativeTimes = getCumulativeTimes(rangeObjectArray[0]); } catch (NumberFormatException e) { throw new IllegalArgumentException("输入的参数不为Integer类型,参数为:" + paramToken, e); } catch (Exception e) { throw new IllegalArgumentException(e); } break; case 3: key = parseKeyPart(paramTokens[0], needAppear); try { atomicIncreateType = getIncreaseType(paramTokens[1]); atomicIncreateValue = getAtomicIncreaseValue(paramTokens[1], atomicIncreateType); rangeObjectArray = parseRangeArray(paramTokens[2]); cumulativeTimes = getCumulativeTimes(rangeObjectArray[0]); } catch (NumberFormatException e) { throw new IllegalArgumentException("输入的参数不为Integer类型,参数为:" + paramToken, e); } catch (Exception e) { throw new IllegalArgumentException(e); } break; default: throw new IllegalArgumentException("错误的参数个数，必须为1个或者3个，3个的时候为允许使用" + "枚举时的数据"); } return new AdvancedParameter(key, atomicIncreateValue, cumulativeTimes, needAppear[0], atomicIncreateType, rangeObjectArray); }
AdvancedParameterParser { public static AdvancedParameter getAdvancedParamByParamTokenNew(String paramToken, boolean completeConfig) { String key; boolean[] needAppear = new boolean[1]; AtomIncreaseType atomicIncreateType = null; Comparable<?> atomicIncreateValue = null; Range[] rangeObjectArray = null; Integer cumulativeTimes = null; String[] paramTokens = TStringUtil.split(paramToken, PARAM_SEGMENT_SPLITOR); switch (paramTokens.length) { case 1: if (completeConfig) { throw new IllegalArgumentException("规则必须配置完全，格式如下:#id,1_number,1024#"); } key = parseKeyPart(paramTokens[0], needAppear); break; case 2: key = parseKeyPart(paramTokens[0], needAppear); atomicIncreateType = AtomIncreaseType.NUMBER; atomicIncreateValue = 1; try { rangeObjectArray = parseRangeArray(paramTokens[1]); cumulativeTimes = getCumulativeTimes(rangeObjectArray[0]); } catch (NumberFormatException e) { throw new IllegalArgumentException("输入的参数不为Integer类型,参数为:" + paramToken, e); } catch (Exception e) { throw new IllegalArgumentException(e); } break; case 3: key = parseKeyPart(paramTokens[0], needAppear); try { atomicIncreateType = getIncreaseType(paramTokens[1]); atomicIncreateValue = getAtomicIncreaseValue(paramTokens[1], atomicIncreateType); rangeObjectArray = parseRangeArray(paramTokens[2]); cumulativeTimes = getCumulativeTimes(rangeObjectArray[0]); } catch (NumberFormatException e) { throw new IllegalArgumentException("输入的参数不为Integer类型,参数为:" + paramToken, e); } catch (Exception e) { throw new IllegalArgumentException(e); } break; default: throw new IllegalArgumentException("错误的参数个数，必须为1个或者3个，3个的时候为允许使用" + "枚举时的数据"); } return new AdvancedParameter(key, atomicIncreateValue, cumulativeTimes, needAppear[0], atomicIncreateType, rangeObjectArray); } }
AdvancedParameterParser { public static AdvancedParameter getAdvancedParamByParamTokenNew(String paramToken, boolean completeConfig) { String key; boolean[] needAppear = new boolean[1]; AtomIncreaseType atomicIncreateType = null; Comparable<?> atomicIncreateValue = null; Range[] rangeObjectArray = null; Integer cumulativeTimes = null; String[] paramTokens = TStringUtil.split(paramToken, PARAM_SEGMENT_SPLITOR); switch (paramTokens.length) { case 1: if (completeConfig) { throw new IllegalArgumentException("规则必须配置完全，格式如下:#id,1_number,1024#"); } key = parseKeyPart(paramTokens[0], needAppear); break; case 2: key = parseKeyPart(paramTokens[0], needAppear); atomicIncreateType = AtomIncreaseType.NUMBER; atomicIncreateValue = 1; try { rangeObjectArray = parseRangeArray(paramTokens[1]); cumulativeTimes = getCumulativeTimes(rangeObjectArray[0]); } catch (NumberFormatException e) { throw new IllegalArgumentException("输入的参数不为Integer类型,参数为:" + paramToken, e); } catch (Exception e) { throw new IllegalArgumentException(e); } break; case 3: key = parseKeyPart(paramTokens[0], needAppear); try { atomicIncreateType = getIncreaseType(paramTokens[1]); atomicIncreateValue = getAtomicIncreaseValue(paramTokens[1], atomicIncreateType); rangeObjectArray = parseRangeArray(paramTokens[2]); cumulativeTimes = getCumulativeTimes(rangeObjectArray[0]); } catch (NumberFormatException e) { throw new IllegalArgumentException("输入的参数不为Integer类型,参数为:" + paramToken, e); } catch (Exception e) { throw new IllegalArgumentException(e); } break; default: throw new IllegalArgumentException("错误的参数个数，必须为1个或者3个，3个的时候为允许使用" + "枚举时的数据"); } return new AdvancedParameter(key, atomicIncreateValue, cumulativeTimes, needAppear[0], atomicIncreateType, rangeObjectArray); }  }
AdvancedParameterParser { public static AdvancedParameter getAdvancedParamByParamTokenNew(String paramToken, boolean completeConfig) { String key; boolean[] needAppear = new boolean[1]; AtomIncreaseType atomicIncreateType = null; Comparable<?> atomicIncreateValue = null; Range[] rangeObjectArray = null; Integer cumulativeTimes = null; String[] paramTokens = TStringUtil.split(paramToken, PARAM_SEGMENT_SPLITOR); switch (paramTokens.length) { case 1: if (completeConfig) { throw new IllegalArgumentException("规则必须配置完全，格式如下:#id,1_number,1024#"); } key = parseKeyPart(paramTokens[0], needAppear); break; case 2: key = parseKeyPart(paramTokens[0], needAppear); atomicIncreateType = AtomIncreaseType.NUMBER; atomicIncreateValue = 1; try { rangeObjectArray = parseRangeArray(paramTokens[1]); cumulativeTimes = getCumulativeTimes(rangeObjectArray[0]); } catch (NumberFormatException e) { throw new IllegalArgumentException("输入的参数不为Integer类型,参数为:" + paramToken, e); } catch (Exception e) { throw new IllegalArgumentException(e); } break; case 3: key = parseKeyPart(paramTokens[0], needAppear); try { atomicIncreateType = getIncreaseType(paramTokens[1]); atomicIncreateValue = getAtomicIncreaseValue(paramTokens[1], atomicIncreateType); rangeObjectArray = parseRangeArray(paramTokens[2]); cumulativeTimes = getCumulativeTimes(rangeObjectArray[0]); } catch (NumberFormatException e) { throw new IllegalArgumentException("输入的参数不为Integer类型,参数为:" + paramToken, e); } catch (Exception e) { throw new IllegalArgumentException(e); } break; default: throw new IllegalArgumentException("错误的参数个数，必须为1个或者3个，3个的时候为允许使用" + "枚举时的数据"); } return new AdvancedParameter(key, atomicIncreateValue, cumulativeTimes, needAppear[0], atomicIncreateType, rangeObjectArray); }  static AdvancedParameter getAdvancedParamByParamTokenNew(String paramToken, boolean completeConfig); }
AdvancedParameterParser { public static AdvancedParameter getAdvancedParamByParamTokenNew(String paramToken, boolean completeConfig) { String key; boolean[] needAppear = new boolean[1]; AtomIncreaseType atomicIncreateType = null; Comparable<?> atomicIncreateValue = null; Range[] rangeObjectArray = null; Integer cumulativeTimes = null; String[] paramTokens = TStringUtil.split(paramToken, PARAM_SEGMENT_SPLITOR); switch (paramTokens.length) { case 1: if (completeConfig) { throw new IllegalArgumentException("规则必须配置完全，格式如下:#id,1_number,1024#"); } key = parseKeyPart(paramTokens[0], needAppear); break; case 2: key = parseKeyPart(paramTokens[0], needAppear); atomicIncreateType = AtomIncreaseType.NUMBER; atomicIncreateValue = 1; try { rangeObjectArray = parseRangeArray(paramTokens[1]); cumulativeTimes = getCumulativeTimes(rangeObjectArray[0]); } catch (NumberFormatException e) { throw new IllegalArgumentException("输入的参数不为Integer类型,参数为:" + paramToken, e); } catch (Exception e) { throw new IllegalArgumentException(e); } break; case 3: key = parseKeyPart(paramTokens[0], needAppear); try { atomicIncreateType = getIncreaseType(paramTokens[1]); atomicIncreateValue = getAtomicIncreaseValue(paramTokens[1], atomicIncreateType); rangeObjectArray = parseRangeArray(paramTokens[2]); cumulativeTimes = getCumulativeTimes(rangeObjectArray[0]); } catch (NumberFormatException e) { throw new IllegalArgumentException("输入的参数不为Integer类型,参数为:" + paramToken, e); } catch (Exception e) { throw new IllegalArgumentException(e); } break; default: throw new IllegalArgumentException("错误的参数个数，必须为1个或者3个，3个的时候为允许使用" + "枚举时的数据"); } return new AdvancedParameter(key, atomicIncreateValue, cumulativeTimes, needAppear[0], atomicIncreateType, rangeObjectArray); }  static AdvancedParameter getAdvancedParamByParamTokenNew(String paramToken, boolean completeConfig); static final String PARAM_SEGMENT_SPLITOR; static final char NEED_APPEAR_SYMBOL; static final String INCREASE_TYPE_SPLITOR; static final String RANGE_SEGMENT_SPLITOR; static final String RANGE_SEGMENT_START_END_SPLITOR; }