title: Right way to implement equals contract
body: <p>I have a domain object called <strong>User</strong>. Properties of user include ssoId, name, email, createdBy, createdDate and userRole. Of these, <strong>ssoId must be unique</strong> in the sense no two users can have the same sso id. So my equals method checks for the sso id and returns either true or false.</p>
  
  <pre><code>@Override public boolean equals(Object o) {
      if (!(o instanceof User))
        return false;
      return user.getSsoId().equals((User)o.getSsoId());
  }
  </code></pre>
  
  <p>What I feel is that this is an incorrect implementation, though it is correct as far as the business rules are concerned. The above implementation will return true for two objects with same sso id but with different values for say name or email or both. Should I change my equals contract to check the equality of all fields? What is your suggestion?</p>