Diffable
- @FunctionalInterface public abstract interface org.apache.commons.lang3.builder.Diffable<T>[source]
Diffableclasses can be compared with other objects for differences. TheDiffResultobject retrieved can be queried for a list of differences or printed using theDiffResult#toString().The calculation of the differences is consistent with equals if and only if
d1.equals(d2)impliesd1.diff(d2) == "". It is strongly recommended that implementations are consistent with equals to avoid confusion. Note thatnullis not an instance of any class andd1.diff(null)should throw aNullPointerException.Diffableclasses 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);
- Parameters:
<T> – The type of objects that this object may be differentiated against
- Since:
3.3
Methods
Retrieves a list of the differences between this object and the supplied object. |
- public abstract DiffResult<T> diff(T obj)[source]
Retrieves a list of the differences between this object and the supplied object.
- Parameters:
obj – The object to diff against, can be
null- Returns:
A list of differences
- Throws:
java.lang.NullPointerException – Thrown if the specified object is
null.