i have a class whose equality is based on 2 fields such that if either one is equal then the objects of this type are considered equal. how can i write a hashCode() function for
After re-read the question.
You may auto-complete the another field when one of them being updated.
--
EDIT: My code may say better then my English.
void setName(String value){
this.id=Lookup.IDbyName(value);
}
void setID(String value){
this.name=Lookup.NamebyId(value);
}
EDIT 2:
The code on the question may wrong as will always return true unless you've set both the id & name.
If you really want a method that do partial equals, create you own API that named "partialEquals()".