title: How do you declare an abstract method so that the parameter type (class) is always the Children class?
body: <p><strong>EDIT : see bottom</strong></p>
  
  <p>First off I searched for an answer before asking this one, but as you can see with the title I have no idea how this is called and I will edit the question whenever I can.
  Please forgive me on this.</p>
  
  <p>I have the following abstract class :</p>
  
  <pre><code>public abstract class ValidableDTO implements Serializable {
      public abstract boolean isValid();
      public abstract boolean equals(ValidableDTO compared);
      // EDIT : new solution
      public abstract &lt;T extends ValidableDTO&gt; boolean equals(T compared);
  }
  </code></pre>
  
  <p>I'd like to get a similar implementation :</p>
  
  <pre><code>public class MyDTO extends ValidableDTO {
  
      private String myValue; //With a getter and setter of course
  
      public MyDTO() {
          // ...
      }
  
      @Override
      public boolean isValid() {
          return true; // Validation
      }
  
  // __________ LOOK AT THE FOLLOWING PARAMETER TYPE __________­­
      @Override
      public boolean equals(MyDTO compared) {
          return true; // Comparison
      }
  }
  </code></pre>
  
  <p>The closest I could get is</p>
  
  <pre><code>@Override
  public boolean equals(ValidableDTO compared) {
      boolean isEqual = false;
  
      if (compared instanceof MyDTO) {
          isEqual = getValue().equals(compared.getValue());
      }
  
      return isEqual;
  }
  </code></pre>
  
  <p>I tried using <code>public abstract boolean equals(&lt;? extends ValidableDTO&gt; compared);</code> but this doesn't work.</p>
  
  <p>Is that even <strong>possible</strong> (it <em>should</em> be IMO) ? Thank you for your time and ... I still don't know how to describe this in 1 sentence... (lol)</p>
  
  <p>Sincerely.
   - me</p>
  
  <p><strong>One step closer, thanks to user : aps !</strong></p>
  
  <p>the following works in the Abstract class definition (ValidableDTO)</p>
  
  <pre><code>public abstract &lt;T extends ValidableDTO&gt; boolean equals(T compared);
  </code></pre>
  
  <p><strong>__<em>BUT</em>__</strong></p>
  
  <p>the implementation in MyDTO still isn't fine and in the end, it's exactly the same as using my 'if instanceof' solution because ValidableDTO is an abstract class and HAS to be inherited.</p>
  
  <p>What it looks like for now using Aps' solution :</p>
  
  <pre><code>public &lt;T extends ValidableDTO&gt; boolean equals(T compared) { ... }
  </code></pre>
  
  <p>I still have to check if it's a MyDTO instance...</p>
  
  <p>ON A SIDE NOTE, google doesn't seem to know if "Validable" or "Validatable" are real words.. which one is correct?</p>