DiffResult contains a collection of the differences between two
Diffable objects. Typically these differences are displayed using
toString() method, which returns a string describing the fields that
differ between the objects.
Use a DiffBuilder to build a DiffResult comparing two objects.
| Modifier and Type | Field and Description |
|---|---|
| private final List | |
| private final T | |
| public static final String | OBJECTS_SAME_STRING
The |
| private final T | |
| private final ToStringStyle | |
| private final String |
| Access | Constructor and Description |
|---|---|
| pack-priv | DiffResult(final T
the left-hand side object lhs, final T the right-hand side object rhs, final List<Diff<?>> the list of differences, may be empty diffList, final ToStringStyle the style to use for the style, final String toString() method. May be
null, in which case
ToStringStyle#DEFAULT_STYLE is usedTwo-argument format string for toStringFormat)String#format(String, Object., for example "%s differs from %s".Creates a |
| Modifier and Type | Method and Description |
|---|---|
| public List | |
| public T | |
| public int | Returns: the number of differencesGets the number of differences between the two objects. |
| public T | Returns: the right object of the diffGets the object the left object has been compared to. |
| public ToStringStyle | |
| public Iterator | Returns: the iteratorImplements java. Returns an iterator over the |
| public String | Returns: aString description of the differences.Overrides java. Builds a |
| public String | Returns: aString description of the differences.the style)ToStringStyle to use when outputting the objectsBuilds a |
| diffList | back to summary |
|---|---|
| private final List<Diff<?>> diffList | |
| lhs | back to summary |
|---|---|
| private final T lhs | |
| OBJECTS_SAME_STRING | back to summary |
|---|---|
| public static final String OBJECTS_SAME_STRING The | |
| rhs | back to summary |
|---|---|
| private final T rhs | |
| style | back to summary |
|---|---|
| private final ToStringStyle style | |
| toStringFormat | back to summary |
|---|---|
| private final String toStringFormat | |
| DiffResult | back to summary |
|---|---|
| pack-priv DiffResult(final T lhs, final T rhs, final List<Diff<?>> diffList, final ToStringStyle style, final String toStringFormat) Creates a
| |
| getDiffs | back to summary |
|---|---|
| public List Gets an unmodifiable list of | |
| getLeft | back to summary |
|---|---|
| public T getLeft() Gets the object the right object has been compared to.
| |
| getNumberOfDiffs | back to summary |
|---|---|
| public int getNumberOfDiffs() Gets the number of differences between the two objects.
| |
| getRight | back to summary |
|---|---|
| public T getRight() Gets the object the left object has been compared to.
| |
| getToStringStyle | back to summary |
|---|---|
| public ToStringStyle getToStringStyle() Gets the style used by the
| |
| iterator | back to summary |
|---|---|
| public Iterator Implements java. Returns an iterator over the | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Builds a
If there are no differences stored in this list, the method will return
Person[name=John Doe,age=32] differs from Person[name=Joe Bloggs,age=26] This indicates that the objects differ in name and age, but not in smoking status.
To use a different | |
| toString | back to summary |
|---|---|
| public String toString(final ToStringStyle style) Builds a
| |