Children should not examine the private members of their parents
But obviously, all significant fields should be taken into account for equality and hashing.
Fortunately, you you can easily satisfy both rules.
Assuming you’re not stuck using the NetBeans-generated equals and hashcode, you can modify Hominidae’s equals method to use instanceof comparison rather than class equality, and then use it straightforwardly. Something like this:
@Override
public boolean equals(Object obj) {
if (obj == null) { return false; }
if (getClass() != obj.getClass()) { return false; }
if (! super.equals(obj)) return false;
else {
// compare subclass fields
}
Of course, hashcode is easy:
@Override
public int hashCode() {
int hash = super.hashCode();
hash = 89 * hash + (this.name != null ? this.name.hashCode() : 0);
hash = 89 * hash + (this.faceBookNickname != null ? this.faceBookNickname.hashCode() : 0);
return hash;
}
Seriously, though: what’s up with NetBeans not taking superclass fields into account by calling the superclass methods?