added equality checks to data model objects

pull/516/head
Justin Richer 2013-09-11 11:57:13 -04:00
parent 77c0473438
commit b1a6127d06
2 changed files with 272 additions and 0 deletions

View File

@ -146,4 +146,88 @@ public class Address {
this.id = id;
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((country == null) ? 0 : country.hashCode());
result = prime * result + ((formatted == null) ? 0 : formatted.hashCode());
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((locality == null) ? 0 : locality.hashCode());
result = prime * result + ((postalCode == null) ? 0 : postalCode.hashCode());
result = prime * result + ((region == null) ? 0 : region.hashCode());
result = prime * result + ((streetAddress == null) ? 0 : streetAddress.hashCode());
return result;
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof Address)) {
return false;
}
Address other = (Address) obj;
if (country == null) {
if (other.country != null) {
return false;
}
} else if (!country.equals(other.country)) {
return false;
}
if (formatted == null) {
if (other.formatted != null) {
return false;
}
} else if (!formatted.equals(other.formatted)) {
return false;
}
if (id == null) {
if (other.id != null) {
return false;
}
} else if (!id.equals(other.id)) {
return false;
}
if (locality == null) {
if (other.locality != null) {
return false;
}
} else if (!locality.equals(other.locality)) {
return false;
}
if (postalCode == null) {
if (other.postalCode != null) {
return false;
}
} else if (!postalCode.equals(other.postalCode)) {
return false;
}
if (region == null) {
if (other.region != null) {
return false;
}
} else if (!region.equals(other.region)) {
return false;
}
if (streetAddress == null) {
if (other.streetAddress != null) {
return false;
}
} else if (!streetAddress.equals(other.streetAddress)) {
return false;
}
return true;
}
}

View File

@ -430,5 +430,193 @@ public class DefaultUserInfo implements UserInfo {
return ui;
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((address == null) ? 0 : address.hashCode());
result = prime * result + ((birthdate == null) ? 0 : birthdate.hashCode());
result = prime * result + ((email == null) ? 0 : email.hashCode());
result = prime * result + ((emailVerified == null) ? 0 : emailVerified.hashCode());
result = prime * result + ((familyName == null) ? 0 : familyName.hashCode());
result = prime * result + ((gender == null) ? 0 : gender.hashCode());
result = prime * result + ((givenName == null) ? 0 : givenName.hashCode());
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((locale == null) ? 0 : locale.hashCode());
result = prime * result + ((middleName == null) ? 0 : middleName.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((nickname == null) ? 0 : nickname.hashCode());
result = prime * result + ((phoneNumber == null) ? 0 : phoneNumber.hashCode());
result = prime * result + ((picture == null) ? 0 : picture.hashCode());
result = prime * result + ((preferredUsername == null) ? 0 : preferredUsername.hashCode());
result = prime * result + ((profile == null) ? 0 : profile.hashCode());
result = prime * result + ((sub == null) ? 0 : sub.hashCode());
result = prime * result + ((updatedTime == null) ? 0 : updatedTime.hashCode());
result = prime * result + ((website == null) ? 0 : website.hashCode());
result = prime * result + ((zoneinfo == null) ? 0 : zoneinfo.hashCode());
return result;
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof DefaultUserInfo)) {
return false;
}
DefaultUserInfo other = (DefaultUserInfo) obj;
if (address == null) {
if (other.address != null) {
return false;
}
} else if (!address.equals(other.address)) {
return false;
}
if (birthdate == null) {
if (other.birthdate != null) {
return false;
}
} else if (!birthdate.equals(other.birthdate)) {
return false;
}
if (email == null) {
if (other.email != null) {
return false;
}
} else if (!email.equals(other.email)) {
return false;
}
if (emailVerified == null) {
if (other.emailVerified != null) {
return false;
}
} else if (!emailVerified.equals(other.emailVerified)) {
return false;
}
if (familyName == null) {
if (other.familyName != null) {
return false;
}
} else if (!familyName.equals(other.familyName)) {
return false;
}
if (gender == null) {
if (other.gender != null) {
return false;
}
} else if (!gender.equals(other.gender)) {
return false;
}
if (givenName == null) {
if (other.givenName != null) {
return false;
}
} else if (!givenName.equals(other.givenName)) {
return false;
}
if (id == null) {
if (other.id != null) {
return false;
}
} else if (!id.equals(other.id)) {
return false;
}
if (locale == null) {
if (other.locale != null) {
return false;
}
} else if (!locale.equals(other.locale)) {
return false;
}
if (middleName == null) {
if (other.middleName != null) {
return false;
}
} else if (!middleName.equals(other.middleName)) {
return false;
}
if (name == null) {
if (other.name != null) {
return false;
}
} else if (!name.equals(other.name)) {
return false;
}
if (nickname == null) {
if (other.nickname != null) {
return false;
}
} else if (!nickname.equals(other.nickname)) {
return false;
}
if (phoneNumber == null) {
if (other.phoneNumber != null) {
return false;
}
} else if (!phoneNumber.equals(other.phoneNumber)) {
return false;
}
if (picture == null) {
if (other.picture != null) {
return false;
}
} else if (!picture.equals(other.picture)) {
return false;
}
if (preferredUsername == null) {
if (other.preferredUsername != null) {
return false;
}
} else if (!preferredUsername.equals(other.preferredUsername)) {
return false;
}
if (profile == null) {
if (other.profile != null) {
return false;
}
} else if (!profile.equals(other.profile)) {
return false;
}
if (sub == null) {
if (other.sub != null) {
return false;
}
} else if (!sub.equals(other.sub)) {
return false;
}
if (updatedTime == null) {
if (other.updatedTime != null) {
return false;
}
} else if (!updatedTime.equals(other.updatedTime)) {
return false;
}
if (website == null) {
if (other.website != null) {
return false;
}
} else if (!website.equals(other.website)) {
return false;
}
if (zoneinfo == null) {
if (other.zoneinfo != null) {
return false;
}
} else if (!zoneinfo.equals(other.zoneinfo)) {
return false;
}
return true;
}
}