Package org.apache.commons.lang3.builder
package org.apache.commons.lang3.builder
Assists in creating consistent equals(Object), toString(), hashCode(), and compareTo(Object) methods.
These classes are not thread-safe.
When you write a hashCode(), do you check Bloch's Effective Java? No?
You just hack in a quick number?
Well HashCodeBuilder will save your day.
It, and its buddies (EqualsBuilder, CompareToBuilder, ToStringBuilder), take care of the nasty bits while you focus on the important bits, like which fields will go into making up the hashcode.
- Since:
- 1.0
- See Also:
-
ClassDescriptionBuilder<T>The Builder interface is designed to designate a class as a builder object in the Builder design pattern.Assists in implementing
Comparable.compareTo(Object)methods.Diff<T>ADiffcontains the differences between twoDiffableclass fields.Diffable<T>Diffableclasses can be compared with other objects for differences.DiffBuilder<T>Assists in implementingDiffable.diff(Object)methods.DiffResult<T>ADiffResultcontains a collection of the differences between twoDiffableobjects.Assists in implementingObject.equals(Object)methods.Use this annotation to exclude a field from being used by the variousreflectionEqualsmethods defined onEqualsBuilder.Assists in implementingObject.hashCode()methods.Use this annotation to exclude a field from being used by the variousreflectionHashcodemethods defined onHashCodeBuilder.Wrap an identity key (System.identityHashCode()) so that an object can only be equal() to itself.Works withToStringBuilderto create a "deep"toString.Works withToStringBuilderto create a "deep"toString.Assists in implementingDiffable.diff(Object)methods.Assists in implementingObject.toString()methods using reflection.Works withToStringBuilderto create atoString.Assists in implementingObject.toString()methods.Use this annotation to exclude a field from being used by theReflectionToStringBuilder.ControlsStringformatting forToStringBuilder.DefaultToStringStyle.ToStringStylethat outputs with JSON format.ToStringStylethat outputs on multiple lines.ToStringStylethat does not print out the classname and identity hash code but prints content start and field names.ToStringStylethat does not print out the field names.ToStringStylethat prints out the short class name and no identity hashcode.ToStringStylethat does not print out the classname, identity hashcode, content start or field name.Use this annotation on the fields to get the summary instead of the detailed information when usingReflectionToStringBuilder.