#137 - Improved TemplateVariables to combine variables.
Request parameters variables {?…} and continued ones {&…} are now combined by TemplateVariables. Improved detection of the base URI and adapted the rendering logic accordingly. UriTemplates can now be augmented with additional TemplateVariables.
Added equals(…) and hashCode() methods for TempalteVariables.
This commit is contained in:
@@ -125,7 +125,7 @@ public final class TemplateVariables implements Iterable<TemplateVariable> {
|
||||
|
||||
if (previous == null) {
|
||||
builder.append("{").append(variable.getType().toString());
|
||||
} else if (!previous.isOfSameTypeAs(variable)) {
|
||||
} else if (!previous.isCombinable(variable)) {
|
||||
builder.append("}{").append(variable.getType().toString());
|
||||
} else {
|
||||
builder.append(",");
|
||||
@@ -137,4 +137,33 @@ public final class TemplateVariables implements Iterable<TemplateVariable> {
|
||||
|
||||
return builder.append("}").toString();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(obj instanceof TemplateVariables)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TemplateVariables that = (TemplateVariables) obj;
|
||||
|
||||
return this.variables.equals(that.variables);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.variables.hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user