#281 - UriTemplate now has convenience method to add a single template variable.

This commit is contained in:
Oliver Gierke
2015-02-10 19:48:56 +01:00
parent 629028a7ef
commit bf9584f91e
2 changed files with 24 additions and 2 deletions

View File

@@ -89,7 +89,7 @@ public class UriTemplate implements Iterable<TemplateVariable>, Serializable {
*/
public UriTemplate(String baseUri, TemplateVariables variables) {
Assert.hasText(baseUri,"Base URI must not be null or empty!");
Assert.hasText(baseUri, "Base URI must not be null or empty!");
this.baseUri = baseUri;
this.variables = variables == null ? TemplateVariables.NONE : variables;
@@ -99,7 +99,7 @@ public class UriTemplate implements Iterable<TemplateVariable>, Serializable {
* Creates a new {@link UriTemplate} with the current {@link TemplateVariable}s augmented with the given ones.
*
* @param variables can be {@literal null}.
* @return
* @return will never be {@literal null}.
*/
public UriTemplate with(TemplateVariables variables) {
@@ -129,6 +129,17 @@ public class UriTemplate implements Iterable<TemplateVariable>, Serializable {
return new UriTemplate(baseUri, this.variables.concat(result));
}
/**
* Creates a new {@link UriTemplate} with a {@link TemplateVariable} with the given name and type added.
*
* @param variableName must not be {@literal null} or empty.
* @param type must not be {@literal null}.
* @return will never be {@literal null}.
*/
public UriTemplate with(String variableName, TemplateVariable.VariableType type) {
return with(new TemplateVariables(new TemplateVariable(variableName, type)));
}
/**
* Returns whether the given candidate is a URI template.
*