title: How to declare field-level type parameters?
body: <p>In the following code sniplet, I want to specify that:</p>
  
  <ol>
  <li><code>attachment</code> and <code>handler</code> share a generic type `</li>
  <li><code>&lt;A&gt;</code>'s type only needs to be specified when <code>notify()</code> is invoked</li>
  <li>Invoking <code>notify()</code> is optional.</li>
  </ol>
  
  <p>I do not want to force users to specify <code>&lt;A&gt;</code> at class construction time because they might never end up invoking <code>notify()</code>.</p>
  
  <pre><code>/**
   * Builder pattern for some asynchronous operation.
   */
  public class OperationBuilder
  {
    private A attachment = null;
    private CompletionHandler&lt;Integer, A&gt; handler = null;
  
    public &lt;A&gt; OperationBuilder notify(A attachment, CompletionHandler&lt;Integer, A&gt; handler)
    {
      this.attachment = attachment;
      this.handler = handler;
      return this;
    }
  
    public abstract build();
  }
  </code></pre>
  
  <p>Is this possible under Java? If not, what would you recommend I do?</p>
  
  <p><strong>UPDATE</strong>: I don't need to specify that <code>&lt;A&gt;</code> associated with <code>attachment</code> and <code>handler</code> must be the same <code>&lt;A&gt;</code> associated with <code>notify()</code>. All I'm trying to specify is that <code>attachment</code> and <code>handler</code> must use the same type <code>&lt;A&gt;</code>.</p>