title: Correct way to extend a class so I can override equals()
body: <p>I have a class in a package that I cannot alter. This class does not override Object.equals() and having a different implementation of equals would really make my code cleaner.</p>
  
  <p>I know I can't do this:</p>
  
  <pre><code>MyClass extends OtherClass{
  @Override
  public boolean equals(MyClass that)
  {
  //compare members and other stuff here
  }
  }
  
  OtherClass oc1 = new OtherClass();
  OtherClass oc2 = new OtherClass();
  oc1.equals(oc2); //false because of Object.equals
  //I want to do something like the following
  MyClass mc1 = (MyClass) oc1; //throws class cast exception
  MyClass mc2 = (MyClass) oc2; //throws class cast exception
  mc1.equals(mc2); //true
  </code></pre>
  
  <p>What is the right way to accomplish this?</p>
  
  <p>I could write a method like equals(OtherClass oc1, OtherClass oc2) but this is less useful. If I can implement equals I can make use of things like List.contains or Sets to manage my data and make life easier.</p>