Package org.apache.commons.lang3.builder
Provides classes to create 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 hash code.
- Since:
- 1.0
- See Also:
Object.equals(Object),Object.toString(),Object.hashCode(),Comparable.compareTo(Object)
-
Interface Summary Interface Description Builder<T> The Builder interface is designed to designate a class as a builder object in the Builder design pattern.Diffable<T> Diffableclasses can be compared with other objects for differences.DiffBuilder.SerializableSupplier<T> Private interface while we still have to support serialization. -
Class Summary Class Description AbstractSupplier<T,B extends AbstractSupplier<T,B,E>,E extends java.lang.Throwable> Abstracts supplying an instance ofT.CompareToBuilder Assists in implementingComparable.compareTo(Object)methods.Diff<T> DiffBuilder<T> Assists in implementingDiffable.diff(Object)methods.DiffBuilder.Builder<T> Constructs a new instance.DiffBuilder.SDiff<T> DiffResult<T> ADiffResultcontains a collection of the differences between twoDiffableobjects.EqualsBuilder Assists in implementingObject.equals(Object)methods.HashCodeBuilder Assists in implementingObject.hashCode()methods.IDKey Wrap an identity key (System.identityHashCode()) so that an object can only be equal() to itself.MultilineRecursiveToStringStyle Works withToStringBuilderto create a "deep"toString.RecursiveToStringStyle Works withToStringBuilderto create a "deep"toString.Reflection Package-private reflection code.ReflectionDiffBuilder<T> Assists in implementingDiffable.diff(Object)methods.ReflectionDiffBuilder.Builder<T> Constructs a new instance.ReflectionToStringBuilder Assists in implementingObject.toString()methods using reflection.StandardToStringStyle Works withToStringBuilderto create atoString.ToStringBuilder Assists in implementingObject.toString()methods.ToStringStyle ControlsStringformatting forToStringBuilder.ToStringStyle.DefaultToStringStyle DefaultToStringStyle.ToStringStyle.JsonToStringStyle ToStringStylethat outputs with JSON format.ToStringStyle.MultiLineToStringStyle ToStringStylethat outputs on multiple lines.ToStringStyle.NoClassNameToStringStyle ToStringStylethat does not print out the class name and identity hash code but prints content start and field names.ToStringStyle.NoFieldNameToStringStyle ToStringStylethat does not print out the field names.ToStringStyle.ShortPrefixToStringStyle ToStringStylethat prints out the short class name and no identity hash code.ToStringStyle.SimpleToStringStyle ToStringStylethat does not print out the class name, identity hash code, content start or field name. -
Annotation Types Summary Annotation Type Description DiffExclude Excludes a field from being used by theReflectionDiffBuilder.EqualsExclude Excludes a field from being used by the variousreflectionEqualsmethods defined onEqualsBuilder.HashCodeExclude Exclude a field from being used by the variousreflectionHashcodemethods defined onHashCodeBuilder.ToStringExclude Excludes a field from being used by theReflectionToStringBuilder.ToStringSummary Use this annotation on the fields to get the summary instead of the detailed information when usingReflectionToStringBuilder.