code: public static String encode(MultiMap<String> map, Charset charset, boolean equalsForNullValue) {
          if (charset == null)
              charset = ENCODING;
  
          StringBuilder result = new StringBuilder(128);
  
          boolean delim = false;
          for (Map.Entry<String, List<String>> entry : map.entrySet()) {
              String key = entry.getKey();
              List<String> list = entry.getValue();
              int s = list.size();
  
              if (delim) {
                  result.append('&');
              }
  
              if (s == 0) {
                  result.append(encodeString(key, charset));
                  if (equalsForNullValue)
                      result.append('=');
              } else {
                  for (int i = 0; i < s; i++) {
                      if (i > 0)
                          result.append('&');
                      String val = list.get(i);
                      result.append(encodeString(key, charset));
  
                      if (val != null) {
                          if (val.length() > 0) {
                              result.append('=');
                              result.append(encodeString(val, charset));
                          } else if (equalsForNullValue)
                              result.append('=');
                      } else if (equalsForNullValue)
                          result.append('=');
                  }
              }
              delim = true;
          }
          return result.toString();
      }
docs: Encode MultiMap with % encoding.
  
  @param map                the map to encode
  @param charset            the charset to use for encoding (uses default encoding if null)
  @param equalsForNullValue if True, then an '=' is always used, even
  for parameters without a value. e.g. <code>"blah?a=&amp;b=&amp;c="</code>.
  @return the MultiMap as a string encoded with % encodings.