title: Is there a way to say "method returns this" in Java?
body: <p>Is there a way to say "this method returns <code>this</code>" using Generics?</p>
  
  <p>Of course, I want to override this method in subclasses, so the declaration should work well with <code>@Override</code>.</p>
  
  <p>Here is an example:</p>
  
  <pre><code>class Base {
      public Base copyTo (Base dest) {
          ... copy all fields to dest ...
          return this;
      }
  }
  class X extends Base {
      @Override
      public X copyTo (X dest) {
          super.copyTo (dest);
          ... copy all fields to dest ...
          return this;
      }
  }
  </code></pre>
  
  <p><code>public &lt;T extends Base&gt; T copyTo (Base dest)</code> doesn't work at all: I get "Type mismatch: Can't convert from Base to T". If I force it with a cast, the override fails.</p>