Commons-lang builders

Jakarta commons-lang provides a convenient way for building consistent equals(Object), toString(), hashCode(), and compareTo(Object) methods. Commons-lang builders are robust and flexible. Probably the most useful builder is the toString() one, which helps you in creating consistent and configurable (through the use of a ToStringStyle object) toString() methods in your project.

Generated methods example


	 * @see java.lang.Object#toString()
	public String toString() {
		return new ToStringBuilder(this, ToStringStyle.SIMPLE_STYLE)
			.append("age", this.age)
			.append("isSmoker", this.isSmoker)


	 * @see java.lang.Object#hashCode()
	public int hashCode() {
		return new HashCodeBuilder(357504959, 1759723435)


	 * @see java.lang.Object#equals(Object)
	public boolean equals(Object object) {
		if (!(object instanceof Person)) {
			return false;
		Person rhs = (Person) object;
		return new EqualsBuilder()
			.append(this.age, rhs.age)
			.append(this.isSmoker, rhs.isSmoker)


	 * @see java.lang.Comparable#compareTo(Object)
	public int compareTo(Object object) {
		Person myClass = (Person) object;
		return new CompareToBuilder()
			.append(this.age, myClass.age)
			.append(this.isSmoker, myClass.isSmoker)