Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
equals() and hashCode() template for Eclipse. It uses EqualsBuilder and HashCodeBuilder in Apache Commons Lang.
public boolean equals(Object object) {
if (object instanceof ${enclosing_type}) {
${enclosing_type} another = (${enclosing_type}) object;
return new EqualsBuilder().append(${replaceWithFieldName}, another.${replaceWithFieldName}).isEquals();
return false;
public int hashCode() {
return new HashCodeBuilder().append(${replaceWithFieldName}).toHashCode();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment