DiffResult¶
- public class org.apache.commons.lang3.builder.DiffResult<T> implements Iterable<Diff<?>>[source]¶
A
DiffResultcontains a collection of the differences between twoDiffableobjects. Typically these differences are displayed using#toString()method, which returns a string describing the fields that differ between the objects.Use a
DiffBuilderto build aDiffResultcomparing two objects.- Parameters:
<T> – type of the left and right object.
- Since:
3.3
Fields and constants¶
The |
Methods¶
Gets an unmodifiable list of |
|
Gets the object the right object has been compared to. |
|
Gets the number of differences between the two objects. |
|
Gets the object the left object has been compared to. |
|
Gets the style used by the |
|
Returns an iterator over the |
|
Builds a |
|
Builds a |
- public List<Diff<?>> getDiffs()[source]¶
Gets an unmodifiable list of
Diffs. The list may be empty if there were no differences between the objects.- Returns:
An unmodifiable list of
Diffs
- public T getLeft()[source]¶
Gets the object the right object has been compared to.
- Returns:
The left object of the diff
- Since:
3.10
- public int getNumberOfDiffs()[source]¶
Gets the number of differences between the two objects.
- Returns:
The number of differences
- public T getRight()[source]¶
Gets the object the left object has been compared to.
- Returns:
The right object of the diff
- Since:
3.10
- public ToStringStyle getToStringStyle()[source]¶
Gets the style used by the
#toString()method.- Returns:
The style
- @Override public Iterator<Diff<?>> iterator()[source]¶
Returns an iterator over the
Diffobjects contained in this list.- Returns:
The iterator
- @Override public String toString()[source]¶
Builds a
Stringdescription of the differences contained within thisDiffResult. AToStringBuilderis used for each object and the style of the output is governed by theToStringStylepassed to the constructor.If there are no differences stored in this list, the method will return
#OBJECTS_SAME_STRING. Otherwise, using the example given inDiffableandToStringStyle#SHORT_PREFIX_STYLE, an output might be: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
ToStringStylefor an instance of this class, use#toString(ToStringStyle).- Returns:
A
Stringdescription of the differences.
- public String toString(ToStringStyle style)[source]¶
Builds a
Stringdescription of the differences contained within thisDiffResult, using the suppliedToStringStyle.- Parameters:
style – the
ToStringStyleto use when outputting the objects- Returns:
A
Stringdescription of the differences.