code: public static URI addParams(
              final URI uri, final Multimap<String, String> params, final Set<String> overrideParams) {
          if (params == null || params.isEmpty()) {
              return uri;
          }
          final String origTxt = uri.toString();
          int queryStart = origTxt.indexOf('?');
          final StringBuilder result = new StringBuilder();
          if (queryStart < 0) {
              int fragmentStart = origTxt.indexOf('#');
              if (fragmentStart < 0) {
                  result.append(origTxt);
              } else {
                  result.append(origTxt, 0, fragmentStart);
              }
          } else {
              result.append(origTxt, 0, queryStart);
          }
  
          Map<String, Collection<String>> origParams = getParameters(uri).asMap();
          boolean first = true;
          for (Map.Entry<String, Collection<String>> param: params.asMap().entrySet()) {
              final String key = param.getKey();
              Collection<String> origList = origParams.remove(key);
              if (origList != null && (overrideParams == null || !overrideParams.contains(key))) {
                  first = addParams(result, first, key, origList);
              }
              Collection<String> list = param.getValue();
              first = addParams(result, first, key, list);
          }
  
          for (Map.Entry<String, Collection<String>> param: origParams.entrySet()) {
              final String key = param.getKey();
              Collection<String> list = param.getValue();
              first = addParams(result, first, key, list);
          }
  
          if (uri.getFragment() != null) {
              result.append('#').append(uri.getRawFragment());
          }
  
          try {
              return new URI(result.toString());
          } catch (URISyntaxException e) {
              throw ExceptionUtils.getRuntimeException(e);
          }
      }
docs: Add the given params to the query.
  
  @param uri The query
  @param params The params to add
  @param overrideParams A set of parameter names that must be overridden and not added
  @return The new query