Created
July 28, 2011 14:41
-
-
Save s4nchez/1111657 to your computer and use it in GitHub Desktop.
IntelliJ IDEA Live Template for equals() and hashCode() using apache commons
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
@Override | |
public boolean equals(final Object obj) { | |
if (obj == null) { | |
return false; | |
} | |
if (obj == this) { | |
return true; | |
} | |
if (obj.getClass() != getClass()) { | |
return false; | |
} | |
final $CLASS$ rhs = ($CLASS$) obj; | |
return new EqualsBuilder() | |
.append(object, rhs.object) | |
.isEquals(); | |
} | |
@Override | |
public int hashCode() { | |
return new HashCodeBuilder(13, 17) | |
.append(object) | |
.toHashCode(); | |
} | |
@Override | |
public String toString() { | |
return new ToStringBuilder(this) | |
.append(object) | |
.toString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice!
Is it possible to generate random values for the HashCodeBuilder? See Apache commons javadocs.