Skip to content

Instantly share code, notes, and snippets.

@KiryhaPikoff
Created September 6, 2019 21:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KiryhaPikoff/a64486ef054416f1186bcd66379c7a32 to your computer and use it in GitHub Desktop.
Save KiryhaPikoff/a64486ef054416f1186bcd66379c7a32 to your computer and use it in GitHub Desktop.
@Override
public int hashCode() {
int result = 1;
result = result * 16 + (this.person == null ? 21 : this.person.hashCode());
result = result * 16 + (this.visits == null ? 21 : this.visits.hashCode());
result = result * 16 + (this.specialization == null ? 21 : this.specialization.hashCode());
result = result * 16 + (this.salary == null ? 21 : this.salary.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if(obj == this) {
return true;
} else if(obj == null) {
return false;
} else if(!(obj instanceof Doctor)) {
return false;
} else {
Doctor other = (Doctor) obj;
Person thisPerson = this.person;
Person otherPerson = other.getPerson();
if(thisPerson == null) {
if(otherPerson != null) {
return false;
}
} else if(!thisPerson.equals(otherPerson)) {
return false;
}
List<Visit> thisVisits = this.visits;
List<Visit> otherVisits = other.getVisits();
if(thisVisits == null) {
if(otherVisits != null) {
return false;
}
} else if(!thisVisits.equals(otherVisits)) {
return false;
}
String thisSpecialization = this.specialization;
String otherSpecialization = other.getSpecialization();
if(thisSpecialization == null) {
if(otherSpecialization != null) {
return false;
}
} else if(!thisSpecialization.equals(otherSpecialization)) {
return false;
}
Integer thisSalary = this.salary;
Integer otherSalary = other.getSalary();
if(thisSalary == null) {
if(otherSalary != null) {
return false;
}
} else if(!thisSalary.equals(otherSalary)) {
return false;
}
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment