URLUtils { @Nonnull public static Map<String, List<String>> resolveParametersMap(String url) { String queryString = StringUtils.substringAfterLast(url, SeparatorConstants.QUERY_STRING); if (StringUtils.isNotBlank(queryString)) { Map<String, List<String>> parametersMap = Maps.newLinkedHashMap(); String[] queryParams = StringUtils.split(queryString, Constants.AND); if (queryParams != null) { for (String queryParam : queryParams) { String[] paramNameAndValue = StringUtils.split(queryParam, Constants.EQUAL); if (paramNameAndValue.length > 0) { String paramName = paramNameAndValue[0]; String paramValue = paramNameAndValue.length > 1 ? paramNameAndValue[1] : StringUtils.EMPTY; List<String> paramValueList = parametersMap.get(paramName); if (paramValueList == null) { paramValueList = Lists.newLinkedList(); parametersMap.put(paramName, paramValueList); } paramValueList.add(paramValue); } } } return Collections.unmodifiableMap(parametersMap); } else { return Collections.emptyMap(); } }  static String resolveRelativePath(URL archiveFileURL); static File resolveArchiveFile(URL archiveFileURL, String archiveFileExtensionName); @Nonnull static Map<String, List<String>> resolveParametersMap(String url); static String resolvePath(final String path); static String encode(String value, String encoding); static String encode(String value); static String decode(String value); static String decode(String value, String encoding); static boolean isDirectoryURL(URL url); static boolean isJarURL(URL url); static String buildURI(String... paths);  }
@Test public void testResolveParametersMap() { String url = "https: Map<String, List<String>> parametersMap = URLUtils.resolveParametersMap(url); Map<String, List<String>> expectedParametersMap = Maps.newLinkedHashMap(); expectedParametersMap.put("q", Arrays.asList("java")); expectedParametersMap.put("oq", Arrays.asList("java")); expectedParametersMap.put("sourceid", Arrays.asList("chrome")); expectedParametersMap.put("es_sm", Arrays.asList("122")); expectedParametersMap.put("ie", Arrays.asList("UTF-8")); Assert.assertEquals(expectedParametersMap, parametersMap); url = "https: parametersMap = URLUtils.resolveParametersMap(url); expectedParametersMap = Collections.emptyMap(); Assert.assertEquals(expectedParametersMap, parametersMap); url = "https: parametersMap = URLUtils.resolveParametersMap(url); expectedParametersMap = Collections.emptyMap(); Assert.assertEquals(expectedParametersMap, parametersMap); }