Created
August 23, 2011 10:57
-
-
Save runeflobakk/1164848 to your computer and use it in GitHub Desktop.
equals() and hashCode() template for Eclipse. It uses EqualsBuilder and HashCodeBuilder in Apache Commons Lang.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
${e:import(org.apache.commons.lang3.builder.EqualsBuilder)} | |
${h:import(org.apache.commons.lang3.builder.HashCodeBuilder)} | |
@Override | |
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; | |
} | |
@Override | |
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