class URLBuilder {

    private final StringBuilder url;

    public URLBuilder(String url) {
      this.url = new StringBuilder(url);
    }

    public URLBuilder(URL url) {
      this(url.toString());
    }

    public URLBuilder addQueryParameter(String key, String value) {<FILL_FUNCTION_BODY>}

    public URL build() {
      try {
        return new URL(toString());
      } catch (MalformedURLException e) {
        throw new IllegalArgumentException(e.getMessage(), e);
      }
    }

    @Override
    public String toString() {
      return this.url.toString();
    }

  }

      if (url.indexOf("?") == -1) {
        url.append("?");
      } else {
        url.append("&");
      }
      url.append(encodeToUTF(key).replaceAll("[+]", "%20")).append("=").append(encodeToUTF(value).replaceAll("[+]", "%20"));
      return this;
    
<no_super_class>