I just wanted to take the time to share with you a code template that I created that has been very helpful in a project that I am currently working on. This template will give you the ability to create the toString(), equals(), hashCode() methods using the Jakarta Commons library. Enjoy:
${:import(org.apache.commons.lang.builder.EqualsBuilder,org.apache.commons.lang.builder.HashCodeBuilder,org.apache.commons.lang.builder.ReflectionToStringBuilder)}
@Override
public boolean equals(Object obj) {
return EqualsBuilder.reflectionEquals(this, obj);
}
@Override
public String toString() {
return ReflectionToStringBuilder.toString(this);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
No comments:
Post a Comment