title: A curious way of passing a parameter to a method
body: <p>I was going through the <a href="https://github.com/buckett/ews-java" rel="nofollow">Exchange Web Services Java API</a> code and saw a design choice in the way the developers passed arguments to their methods. May you can help explain the benefits of the technique --</p>
  
  <p>The type that is to be processed by the method is wrapped by a Generic Wrapper class before being passed into the method, for example if the method is to work on a String, new Param() is passed into the method where Param is defined as follows</p>
  
  <pre><code>class Param&lt;T&gt; {
    private T param; 
    public T getParam() { return param; }
    public void setParam(T param) { this.param = param }
  }
  </code></pre>
  
  <p>Here is a snippet from the source -- The method works on an HttpWebRequest object.<br>
  The caller creates an instance of the Param, i.e. bounded by the HttpWebRequest class. Then that instance is passed into the method, as you can see in the method signature  -- </p>
  
  <pre><code>protected HttpWebRequest emit(OutParam&lt;HttpWebRequest&gt; request) 
  throws Exception {
     request.setParam(this.getService().prepareHttpWebRequest()); 
     OutputStream urlOutStream = request.getParam().getOutputStream();
     EwsServiceXmlWriter writer = new EwsServiceXmlWriter(this.service,urlOutStream);
     this.writeToXml(writer);
     urlOutStream.flush();
     urlOutStream.close();
     writer.dispose();
  
     request.getParam().executeRequest();
     if(request.getParam().getResponseCode() &gt;= 400)
     {
        throw new Exception("The remote server returned an error:("+request.getParam().getResponseCode()+")"+request.getParam().getResponseText());
      }
      return request.getParam();
  }
  </code></pre>
  
  <p>Then why not just pass the HttpWebRequest object --
  The developers use this pattern repeatedly all over the code base which makes me think there is some good reason for it. But I just can't see the benefit... please enlighten.</p>