Apache Commons project represents a set of reusable Java components. Apache Commons Lang is one of the Apache Commons components. It provides much needed additions to the standard JDK's java.lang
package. One of its packages, org.apache.commons.lang3.builder contains a set of very useful builders that helps in creating consistent equals()
, hashCode()
, toString()
and compareTo()
methods.
In this post, I will show how to generate equals()
, hashCode()
, toString()
and compareTo()
methods using Apache Commons Lang builders in Eclipse. For demonstrations I will use the latest stable release - Apache Commons Lang 3.0. Note that Lang 3.0 uses a different package (org.apache.commons.lang3
) than its predecessors (org.apache.commons.lang
). All the examples presented in this post will work also with the previous Apache Commons Lang releases; just change the package name from lang3
to lang
.
Read full article from Thinking about IT: How to generate equals(), hashCode(), toString() and compareTo() using Apache Commons Lang in Eclipse
No comments:
Post a Comment