public class DiffResult extends java.lang.Object implements java.lang.Iterable<Diff<?>>
A 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 |
---|---|
static java.lang.String |
OBJECTS_SAME_STRING
The
String returned when the objects have no differences:
"" |
Modifier and Type | Method and Description |
---|---|
java.util.List<Diff<?>> |
getDiffs()
Returns an unmodifiable list of
Diff s. |
int |
getNumberOfDiffs()
Returns the number of differences between the two objects.
|
ToStringStyle |
getToStringStyle()
Returns the style used by the
toString() method. |
java.util.Iterator<Diff<?>> |
iterator()
Returns an iterator over the
Diff objects contained in this list. |
java.lang.String |
toString()
Builds a
String description of the differences contained within
this DiffResult . |
java.lang.String |
toString(ToStringStyle style)
Builds a
String description of the differences contained within
this DiffResult , using the supplied ToStringStyle . |
public static final java.lang.String OBJECTS_SAME_STRING
The String
returned when the objects have no differences:
""
public java.util.List<Diff<?>> getDiffs()
Returns an unmodifiable list of Diff
s. The list may be empty if
there were no differences between the objects.
Diff
spublic int getNumberOfDiffs()
Returns the number of differences between the two objects.
public ToStringStyle getToStringStyle()
Returns the style used by the toString()
method.
public java.lang.String toString()
Builds a String
description of the differences contained within
this DiffResult
. A ToStringBuilder
is used for each object
and the style of the output is governed by the ToStringStyle
passed to the constructor.
If there are no differences stored in this list, the method will return
OBJECTS_SAME_STRING
. Otherwise, using the example given in
Diffable
and ToStringStyle.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 ToStringStyle
for an instance of this class,
use toString(ToStringStyle)
.
toString
in class java.lang.Object
String
description of the differences.public java.lang.String toString(ToStringStyle style)
Builds a String
description of the differences contained within
this DiffResult
, using the supplied ToStringStyle
.
style
- the ToStringStyle
to use when outputting the objectsString
description of the differences."Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"