VariableType type = VariableType.from(matcher.group(1)); String[] names = matcher.group(2).split(",");
/** * Creates a new {@link UriTemplate} using the given template string. * * @param template must not be {@literal null} or empty. */ public UriTemplate(String template) { Assert.hasText(template, "Template must not be null or empty!"); Matcher matcher = VARIABLE_REGEX.matcher(template); int baseUriEndIndex = template.length(); List<TemplateVariable> variables = new ArrayList<TemplateVariable>(); while (matcher.find()) { int start = matcher.start(0); VariableType type = VariableType.from(matcher.group(1)); String[] names = matcher.group(2).split(","); for (String name : names) { TemplateVariable variable = new TemplateVariable(name, type); if (!variable.isRequired() && start < baseUriEndIndex) { baseUriEndIndex = start; } variables.add(variable); } } this.variables = variables.isEmpty() ? TemplateVariables.NONE : new TemplateVariables(variables); this.baseUri = template.substring(0, baseUriEndIndex); }
TemplateVariable.VariableType type = TemplateVariable.VariableType.from(matcher.group(1));
TemplateVariable.VariableType type = TemplateVariable.VariableType.from(matcher.group(1));