/** * Construct a GoogleUrl from a server, template and a parameter block. * * @param encodedServerUrl encoded URL of the server * @param pathTemplate path template * @param parameters an object with parameters designated by Key annotations. If the template has * no variable references, parameters may be {@code null}. * @throws IllegalArgumentException if a requested element in the pathTemplate is not in the * parameters * * @since 1.3 */ public static GoogleUrl create(String encodedServerUrl, String pathTemplate, Object parameters) throws IllegalArgumentException { GoogleUrl url = new GoogleUrl(encodedServerUrl); HashMap<String, Object> requestMap = new HashMap<String, Object>(); for (Map.Entry<String, Object> entry : Data.mapOf(parameters).entrySet()) { Object value = entry.getValue(); if (value != null) { requestMap.put(entry.getKey(), value); } } url.appendRawPath(expandUriTemplates(pathTemplate, requestMap)); // all other parameters are assumed to be query parameters url.putAll(requestMap); return url; }