Override of equals() MUST compare getClass() OR be final

A good rule suggestion:
@Override equals() MUST compare getClass() OR be final.

public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null) return false;
    if (!(o instanceof User)) return false;
    User user = (User) o;
    return id == user.id 
      && (name.equals(user.name) 
      && email.equals(user.email));
}
  • Complaint Solution
public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null) return false;
    if (this.getClass() != o.getClass()) return false;
    User user = (User) o;
    return id == user.id 
      && (name.equals(user.name) 
      && email.equals(user.email));
}
  • Other Compliant Solution
final public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null) return false;
    if (!(o instanceof User)) return false;
    User user = (User) o;
    return id == user.id 
      && (name.equals(user.name) 
      && email.equals(user.email));
}

EDIT
Thanks for the feedback, I have improved the use of markdown some…
I agree that this could be closed as a duplicate of any one of these.
https://jira.sonarsource.com/browse/RSPEC-2162
https://jira.sonarsource.com/browse/RSPEC-2161
https://jira.sonarsource.com/browse/RSPEC-2097

I’m not seeing how to close it (or delete it) myself.

hello @Brian_Davis,

this seems to be similar to this rule we already have
https://jira.sonarsource.com/browse/RSPEC-2162

Can you please have a look and confirm/explain the difference?

Also can you please format your code samples with markdown, they are bit hard to read.