Skip to content

Instantly share code, notes, and snippets.

@bradleybeddoes
Created November 30, 2010 01:22
Show Gist options
  • Select an option

  • Save bradleybeddoes/720964 to your computer and use it in GitHub Desktop.

Select an option

Save bradleybeddoes/720964 to your computer and use it in GitHub Desktop.
public boolean equals(Object obj) {
if (obj == null) { return false; }
if (obj == this) { return true; }
if (obj.getClass() != getClass()) {
return false;
}
Uri rhs = (Uri) obj;
return new EqualsBuilder()
.appendSuper(super.equals(obj))
.append(uri, rhs.uri)
.append(description, rhs.description)
.append(dateCreated, rhs.dateCreated)
.isEquals();
}
public int hashCode() {
// hard-coded, randomly chosen, non-zero, odd number different for each class
return new HashCodeBuilder(99, 297).
append(uri).
append(description).
append(dateCreated).
toHashCode();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment