Top Description Methods
org.apache.commons.lang3.builder

public Interface Diffable<T>

Annotations
@FunctionalInterface
Type Parameters
<T>
the type of objects that this object may be differentiated against

Diffable classes can be compared with other objects for differences. The DiffResult object retrieved can be queried for a list of differences or printed using the DiffResult#toString().

The calculation of the differences is consistent with equals if and only if d1.equals(d2) implies d1.diff(d2) == "". It is strongly recommended that implementations are consistent with equals to avoid confusion. Note that null is not an instance of any class and d1.diff(null) should throw a NullPointerException.

Diffable classes lend themselves well to unit testing, in which a easily readable description of the differences between an anticipated result and an actual result can be retrieved. For example:

Assert.assertEquals(expected.diff(result), expected, result);
Since
3.3

Method Summary

Modifier and TypeMethod and Description
public DiffResult<T>

Returns:

a list of differences
diff
(T
the object to diff against, can be null
obj
)

Retrieves a list of the differences between this object and the supplied object.

Method Detail

diffback to summary
public DiffResult<T> diff(T obj)

Retrieves a list of the differences between this object and the supplied object.

Parameters
obj:T

the object to diff against, can be null

Returns:DiffResult<T>

a list of differences

Exceptions
NullPointerException:
if the specified object is null