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. -
Class Summary Class Description AbstractReflection Abstracts reflection access for reflection-based classes in this package.AbstractReflection.AbstractBuilder<B extends AbstractReflection.AbstractBuilder<B>> Builds an instance of a subclass ofAbstractReflection.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.CompareToBuilder.Builder Builds instances of CompareToBuilder.Diff<T> DiffBuilder<T> Assists in implementingDiffable.diff(Object)methods.DiffBuilder.Builder<T> Constructs a new instance.DiffResult<T> ADiffResultcontains a collection of the differences between twoDiffableobjects.EqualsBuilder Assists in implementingObject.equals(Object)methods.EqualsBuilder.Builder Builds instances of CompareToBuilder.HashCodeBuilder Assists in implementingObject.hashCode()methods.HashCodeBuilder.Builder Builds instances of CompareToBuilder.MultilineRecursiveToStringStyle Works withToStringBuilderto create a "deep"toString.RecursiveToStringStyle Works withToStringBuilderto create a "deep"toString.RecursiveToStringStyle.Builder Builder forRecursiveToStringStyleinstances.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.ToStringBuilder.Builder Builds instances of CompareToBuilder.ToStringStyle ControlsStringformatting forToStringBuilder. -
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.