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 hash code.
- Since:
- 1.0
- See Also:
-
ClassDescriptionAbstractSupplier<T,
B extends AbstractSupplier<T, B, E>, E extends Throwable> Abstracts supplying an instance ofT
.Builder<T>The Builder interface is designed to designate a class as a builder object in the Builder design pattern.Assists in implementingComparable.compareTo(Object)
methods.Diff<T>Diffable<T>Diffable
classes can be compared with other objects for differences.DiffBuilder<T>Assists in implementingDiffable.diff(Object)
methods.Constructs a new instance.Excludes a field from being used by theReflectionDiffBuilder
.DiffResult<T>ADiffResult
contains a collection of the differences between twoDiffable
objects.Assists in implementingObject.equals(Object)
methods.Excludes a field from being used by the variousreflectionEquals
methods defined onEqualsBuilder
.Assists in implementingObject.hashCode()
methods.Exclude a field from being used by the variousreflectionHashcode
methods defined onHashCodeBuilder
.Wrap an identity key (System.identityHashCode()) so that an object can only be equal() to itself.Works withToStringBuilder
to create a "deep"toString
.Works withToStringBuilder
to create a "deep"toString
.Package-private reflection code.Assists in implementingDiffable.diff(Object)
methods.Constructs a new instance.Assists in implementingObject.toString()
methods using reflection.Works withToStringBuilder
to create atoString
.Assists in implementingObject.toString()
methods.Excludes a field from being used by theReflectionToStringBuilder
.ControlsString
formatting forToStringBuilder
.DefaultToStringStyle
.ToStringStyle
that outputs with JSON format.ToStringStyle
that outputs on multiple lines.ToStringStyle
that does not print out the class name and identity hash code but prints content start and field names.ToStringStyle
that does not print out the field names.ToStringStyle
that prints out the short class name and no identity hash code.ToStringStyle
that does not print out the class name, identity hash code, content start or field name.Use this annotation on the fields to get the summary instead of the detailed information when usingReflectionToStringBuilder
.