code: public static Map<String, String> parseQueryString(String query) {
      Map<String, String> queryMap = new HashMap<>();
      if (query == null || query.isEmpty()) {
        return queryMap;
      }
      // The query string should escape '&'.
      String[] entries = query.split(String.valueOf(QUERY_SEPARATOR));
  
      try {
        for (String entry : entries) {
          // There should be at most 2 parts, since key and value both should escape '='.
          String[] parts = entry.split(String.valueOf(QUERY_KEY_VALUE_SEPARATOR));
          if (parts.length == 0) {
            // Skip this empty entry.
          } else if (parts.length == 1) {
            // There is no value part. Just use empty string as the value.
            String key = URLDecoder.decode(parts[0], "UTF-8");
            queryMap.put(key, "");
          } else {
            // Save the key and value.
            String key = URLDecoder.decode(parts[0], "UTF-8");
            String value = URLDecoder.decode(parts[1], "UTF-8");
            queryMap.put(key, value);
          }
        }
      } catch (UnsupportedEncodingException e) {
        // This is unexpected.
        throw new RuntimeException(e);
      }
      return queryMap;
    }
docs: Parses the given query string, and returns a map of the query parameters.
  
  @param query the query string to parse
  @return the map of query keys and values