Added methods to ModifyRequest to add multiple query parameters

This commit is contained in:
Ignasi Barrera 2011-10-25 11:11:15 +02:00 committed by Adrian Cole
parent 45a1bcac85
commit 69163eb447
1 changed files with 15 additions and 0 deletions

View File

@ -102,6 +102,21 @@ public class ModifyRequest {
return (R) request.toBuilder().endpoint(builder.build()).build();
}
public static <R extends HttpRequest> R addQueryParams(R request, Multimap<String, String> parameters, UriBuilder builder) {
return addQueryParams(request, parameters, builder, request.getSkips());
}
@SuppressWarnings("unchecked")
public static <R extends HttpRequest> R addQueryParams(R request,
Multimap<String, String> parameters, UriBuilder builder, char... skips) {
builder.uri(request.getEndpoint());
Multimap<String, String> map =
org.jclouds.http.utils.ModifyRequest.parseQueryToMap(request.getEndpoint().getQuery());
map.putAll(parameters);
builder.replaceQuery(org.jclouds.http.utils.ModifyRequest.makeQueryLine(map, null, skips));
return (R) request.toBuilder().endpoint(builder.build()).build();
}
public static <R extends HttpRequest> R replaceMatrixParam(R request, String name, Object value, UriBuilder builder) {
return replaceMatrixParam(request, name, new Object[] { value }, builder);
}