Wednesday, December 24, 2008

Merry Christmas...

Merry Christmas everyone....

God Bless...

Friday, December 19, 2008

Eclipse Code Templates - toString, equals, hashCode

Finally I decided to write a code template that I can use in order to create those infamous methods that should be a part of everyone's DTO. Those methods are toString(), equals(), and hashCode().

The template does assume that you are using the commons-lang library. Feel free to use it and pay it forward:


${: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); }
Enjoy.