@Test public void shouldTranslatePatternArgsWithMultipleRegexes() { String uri = new DefaultParametersControl("/test/{hash1:[a-z0-9]{16}}{id}{hash2:[a-z0-9]{16}}/", converters, evaluator).fillUri(new String[] {"hash1", "id", "hash2"}, "0123456789abcdef", "1234", "fedcba9876543210"); assertThat(uri, is(equalTo("/test/0123456789abcdef1234fedcba9876543210/"))); }
public String fillUri(String[] paramNames, Object... paramValues) { if (paramNames.length != paramValues.length) { throw new IllegalArgumentException("paramNames must have the same length as paramValues. Names: " + Arrays.toString(paramNames) + " Values: " + Arrays.toString(paramValues)); } String[] splittedPatterns = StringUtils.extractParameters(originalPattern); String base = originalPattern; for (int i=0; i<parameters.size(); i++) { String key = parameters.get(i); Object param = selectParam(key, paramNames, paramValues); Object result = evaluator.get(param, key); if (result != null) { Class<?> type = result.getClass(); if (converters.existsTwoWayFor(type)) { TwoWayConverter converter = converters.twoWayConverterFor(type); result = converter.convert(result); } } base = base.replace('{' + splittedPatterns[i] + '}', result == null ? "" : result.toString()); } return base.replaceAll("\\.\\*", ""); }
DefaultParametersControl implements ParametersControl { public String fillUri(String[] paramNames, Object... paramValues) { if (paramNames.length != paramValues.length) { throw new IllegalArgumentException("paramNames must have the same length as paramValues. Names: " + Arrays.toString(paramNames) + " Values: " + Arrays.toString(paramValues)); } String[] splittedPatterns = StringUtils.extractParameters(originalPattern); String base = originalPattern; for (int i=0; i<parameters.size(); i++) { String key = parameters.get(i); Object param = selectParam(key, paramNames, paramValues); Object result = evaluator.get(param, key); if (result != null) { Class<?> type = result.getClass(); if (converters.existsTwoWayFor(type)) { TwoWayConverter converter = converters.twoWayConverterFor(type); result = converter.convert(result); } } base = base.replace('{' + splittedPatterns[i] + '}', result == null ? "" : result.toString()); } return base.replaceAll("\\.\\*", ""); } }
DefaultParametersControl implements ParametersControl { public String fillUri(String[] paramNames, Object... paramValues) { if (paramNames.length != paramValues.length) { throw new IllegalArgumentException("paramNames must have the same length as paramValues. Names: " + Arrays.toString(paramNames) + " Values: " + Arrays.toString(paramValues)); } String[] splittedPatterns = StringUtils.extractParameters(originalPattern); String base = originalPattern; for (int i=0; i<parameters.size(); i++) { String key = parameters.get(i); Object param = selectParam(key, paramNames, paramValues); Object result = evaluator.get(param, key); if (result != null) { Class<?> type = result.getClass(); if (converters.existsTwoWayFor(type)) { TwoWayConverter converter = converters.twoWayConverterFor(type); result = converter.convert(result); } } base = base.replace('{' + splittedPatterns[i] + '}', result == null ? "" : result.toString()); } return base.replaceAll("\\.\\*", ""); } DefaultParametersControl(String originalPattern, Map<String, String> parameterPatterns, Converters converters, Evaluator evaluator);  DefaultParametersControl(String originalPattern, Converters converters, Evaluator evaluator); }
DefaultParametersControl implements ParametersControl { public String fillUri(String[] paramNames, Object... paramValues) { if (paramNames.length != paramValues.length) { throw new IllegalArgumentException("paramNames must have the same length as paramValues. Names: " + Arrays.toString(paramNames) + " Values: " + Arrays.toString(paramValues)); } String[] splittedPatterns = StringUtils.extractParameters(originalPattern); String base = originalPattern; for (int i=0; i<parameters.size(); i++) { String key = parameters.get(i); Object param = selectParam(key, paramNames, paramValues); Object result = evaluator.get(param, key); if (result != null) { Class<?> type = result.getClass(); if (converters.existsTwoWayFor(type)) { TwoWayConverter converter = converters.twoWayConverterFor(type); result = converter.convert(result); } } base = base.replace('{' + splittedPatterns[i] + '}', result == null ? "" : result.toString()); } return base.replaceAll("\\.\\*", ""); } DefaultParametersControl(String originalPattern, Map<String, String> parameterPatterns, Converters converters, Evaluator evaluator);  DefaultParametersControl(String originalPattern, Converters converters, Evaluator evaluator); String fillUri(String[] paramNames, Object... paramValues); boolean matches(String uri); void fillIntoRequest(String uri, MutableRequest request); String apply(String[] values); }
DefaultParametersControl implements ParametersControl { public String fillUri(String[] paramNames, Object... paramValues) { if (paramNames.length != paramValues.length) { throw new IllegalArgumentException("paramNames must have the same length as paramValues. Names: " + Arrays.toString(paramNames) + " Values: " + Arrays.toString(paramValues)); } String[] splittedPatterns = StringUtils.extractParameters(originalPattern); String base = originalPattern; for (int i=0; i<parameters.size(); i++) { String key = parameters.get(i); Object param = selectParam(key, paramNames, paramValues); Object result = evaluator.get(param, key); if (result != null) { Class<?> type = result.getClass(); if (converters.existsTwoWayFor(type)) { TwoWayConverter converter = converters.twoWayConverterFor(type); result = converter.convert(result); } } base = base.replace('{' + splittedPatterns[i] + '}', result == null ? "" : result.toString()); } return base.replaceAll("\\.\\*", ""); } DefaultParametersControl(String originalPattern, Map<String, String> parameterPatterns, Converters converters, Evaluator evaluator);  DefaultParametersControl(String originalPattern, Converters converters, Evaluator evaluator); String fillUri(String[] paramNames, Object... paramValues); boolean matches(String uri); void fillIntoRequest(String uri, MutableRequest request); String apply(String[] values);  }