code: protected static String generateQueryString(Map<String, Object> parameters) {
          if (parameters == null || parameters.size() == 0) {
              return "";
          }
          StringBuilder result = new StringBuilder();
          try {
              for(Map.Entry<String, Object> entry : parameters.entrySet()) {
                  // Check to see if the key/value isn't null or empty string
                  if (entry.getKey() != null && (entry.getValue() != null && !entry.getValue().toString().equals(""))) {
                      result.append('&').append(URLEncoder.encode(entry.getKey(), "utf-8")).append("=")
                              .append(URLEncoder.encode(entry.getValue().toString(), "utf-8"));
                  }
              }
          } catch (UnsupportedEncodingException e) {
              throw new RuntimeException(e);
          }
  
          return result.length() == 0 ? "" : "?" + result.substring(1);
      }
docs: Returns a query string.
  
  @param parameters the map of query string keys and values
  @return the query string