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 org.apache.commons.lang3.builder.HashCodeBuilder will save your day. It, and its buddies (org.apache.commons.lang3.builder.EqualsBuilder, org.apache.commons.lang3.builder.CompareToBuilder, org.apache.commons.lang3.builder.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.

See also:
Since:

1.0

Interfaces

Builder

The Builder interface is designed to designate a class as a builder object in the Builder design pattern.

Diffable

Diffable classes can be compared with other objects for differences.

Classes

AbstractReflection

Abstracts reflection access for reflection-based classes in this package.

AbstractReflection.AbstractBuilder

Builds an instance of a subclass of AbstractReflection.

AbstractSupplier

Abstracts supplying an instance of T.

CompareToBuilder

Assists in implementing Comparable#compareTo(Object) methods.

CompareToBuilder.Builder

Builds instances of CompareToBuilder.

Diff

A Diff contains the differences between two Diffable class fields.

DiffBuilder

Assists in implementing Diffable#diff(Object) methods.

DiffBuilder.Builder

Constructs a new instance.

DiffResult

A DiffResult contains a collection of the differences between two Diffable objects.

EqualsBuilder

Assists in implementing Object#equals(Object) methods.

EqualsBuilder.Builder

Builds instances of CompareToBuilder.

HashCodeBuilder

Assists in implementing Object#hashCode() methods.

HashCodeBuilder.Builder

Builds instances of CompareToBuilder.

MultilineRecursiveToStringStyle

Works with ToStringBuilder to create a “deep” toString.

RecursiveToStringStyle

Works with ToStringBuilder to create a “deep” toString.

RecursiveToStringStyle.Builder

Builder for RecursiveToStringStyle instances.

ReflectionDiffBuilder

Assists in implementing Diffable#diff(Object) methods.

ReflectionDiffBuilder.Builder

Constructs a new instance.

ReflectionToStringBuilder

Assists in implementing Object#toString() methods using reflection.

StandardToStringStyle

Works with ToStringBuilder to create a toString.

ToStringBuilder

Assists in implementing Object#toString() methods.

ToStringBuilder.Builder

Builds instances of CompareToBuilder.

ToStringStyle

Controls String formatting for ToStringBuilder.

Annotation types

DiffExclude

Excludes a field from being used by the ReflectionDiffBuilder.

EqualsExclude

Excludes a field from being used by the various reflectionEquals methods defined on EqualsBuilder.

HashCodeExclude

Exclude a field from being used by the various reflectionHashcode methods defined on HashCodeBuilder.

ToStringExclude

Excludes a field from being used by the ReflectionToStringBuilder.

ToStringSummary

Use this annotation on the fields to get the summary instead of the detailed information when using ReflectionToStringBuilder.