Last active
March 13, 2019 08:45
-
-
Save phisad/e85cf688821dc6249f3a06520d590861 to your computer and use it in GitHub Desktop.
Eclipse code template for equals hash toString with apache commons lang3
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
${:import(org.apache.commons.lang3.builder.EqualsBuilder, | |
org.apache.commons.lang3.builder.HashCodeBuilder, | |
org.apache.commons.lang3.builder.ToStringBuilder, | |
org.apache.commons.lang3.builder.ToStringStyle)} | |
@Override | |
public boolean equals(Object aObj) { | |
if(!(aObj instanceof ${enclosing_type})) { | |
return false; | |
} | |
${enclosing_type} tmpOther = (${enclosing_type}) aObj; | |
return new EqualsBuilder().append(${cursor}${field}, tmpOther.${field}).isEquals(); | |
} | |
@Override | |
public int hashCode() { | |
return new HashCodeBuilder().append(${field}).toHashCode(); | |
} | |
@Override | |
public String toString() { | |
return new ToStringBuilder(ToStringStyle.SHORT_PREFIX_STYLE).append(${field}).toString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment