title: Jersey Client / JAX-RS and optional (not default) @QueryParam (client side)
body: <p>I have a RESTful API who's document says that a certain query parameter is optional, and does not supply a default argument.  So, I can either supply the value or not send it in the GET request as a parameter.</p>
  
  <p>Example:</p>
  
  <ul>
  <li><code>queryA</code> is required</li>
  <li><code>queryB</code> is <strong>optional</strong> (can send <code>GET</code> without it)</li>
  </ul>
  
  <p>This should work:</p>
  
  <pre><code>http://www.example.com/service/endpoint?queryA=foo&amp;queryB=bar
  </code></pre>
  
  <p>This should also work:</p>
  
  <pre><code>http://www.example.com/service/endpoint?queryA=foo
  </code></pre>
  
  <p>How do I make an client interface for <a href="https://jersey.java.net/apidocs/2.9/jersey/org/glassfish/jersey/client/proxy/package-summary.html">Jersey-Proxy</a> that can do this?? <strong>I do not have the server-side code</strong> to interface with so I am using <code>org.glassfish.jersey.client.proxy.WebResourceFactory</code> via Jersey-Proxy to generate the client to interact with the server API.</p>
  
  <p>Sample interface:</p>
  
  <pre><code>import javax.ws.rs.Path;
  import javax.ws.rs.Produces;
  import javax.ws.rs.QueryParam;
  import javax.ws.rs.core.Response;
  
  @Path("/service")
  @Produces("application/json")
  public interface ServiceInterface {
  
      @Path("/endpoint")
      @GET
      public Response getEndpoint(
              @QueryParam("queryA") String first,
              @QueryParam("queryB") String second);
  
  }
  </code></pre>
  
  <p>I know I can make another method:</p>
  
  <pre><code>    @Path("/endpoint")
      @GET
      public Response getEndpoint(
              @QueryParam("queryA") String first);
  </code></pre>
  
  <p>But what happens when you have multiple optional fields?? I don't want to make every possible mutation of them!</p>