Diffable#diff(Object) methods.
To use this class, write code as follows:
public class Person implements Diffable<Person> {
String name;
int age;
boolean smoker;
...
public DiffResult<Person> diff(Person obj) {
// No need for null check, as NullPointerException correct if obj is null
return DiffBuilder.<Person>builder()
.setLeft(this)
.setRight(obj)
.setStyle(ToStringStyle.SHORT_PREFIX_STYLE)
.build()
.append("name", this.name, obj.name)
.append("age", this.age, obj.age)
.append("smoker", this.smoker, obj.smoker)
.build();
}
}
The ToStringStyle passed to the constructor is embedded in the returned DiffResult and influences the style of the
DiffResult.toString() method. This style choice can be overridden by calling DiffResult#toString(ToStringStyle).
See ReflectionDiffBuilder for a reflection based version of this class.
Diffable, Diff, DiffResult, ToStringStyle, ReflectionDiffBuilder
| Modifier and Type | Class and Description |
|---|---|
| public static class | |
| private static class | |
| private static interface | DiffBuilder.
the type of results supplied by this supplier. T>Private interface while we still have to support serialization. |
| Modifier and Type | Field and Description |
|---|---|
| private final List | |
| private final boolean | |
| private final T | |
| private final T | |
| private final ToStringStyle | |
| pack-priv static final String | |
| private final String |
| Access | Constructor and Description |
|---|---|
| public | DiffBuilder(final T
this object.the object to diff against. right, final ToStringStyle the style to use when outputting the objects, style)null uses the default.
Deprecated
Use
Builder.
Constructs a builder for the specified objects with the specified style. |
| public | DiffBuilder(final T
this object.the object to diff against. right, final ToStringStyle the style to use when outputting the objects, style, final boolean null uses the default.If true, this will test if lhs and rhs are the same or equal. All of the append(fieldName, lhs, rhs) methods will abort without
creating a field testObjectsEquals)Diff if the trivially equal test is enabled and returns true. The result of this test is never changed
throughout the life of this DiffBuilder.
Deprecated
Use
Builder.
Constructs a builder for the specified objects with the specified style. |
| private | DiffBuilder(final T left, final T right, final ToStringStyle style, final boolean testObjectsEquals, final String toStringFormat)
|
| Modifier and Type | Method and Description |
|---|---|
| private <F> DiffBuilder | add(final String fieldName, final DiffBuilder.
|
| public DiffBuilder | |
| public DiffBuilder | |
| public DiffBuilder | |
| public DiffBuilder | |
| public DiffBuilder | |
| public DiffBuilder | |
| public DiffBuilder | Returns: this instance.the field name. fieldName, final DiffResult<?> the diffResult)DiffResult to append.Appends diffs from another |
| public DiffBuilder | |
| public DiffBuilder | |
| public DiffBuilder | |
| public DiffBuilder | |
| public DiffBuilder | |
| public DiffBuilder | |
| public DiffBuilder | |
| public DiffBuilder | |
| public DiffBuilder | |
| public DiffBuilder | |
| public DiffBuilder | |
| public DiffBuilder | |
| public DiffResult | Returns: aDiffResult containing the differences between the two objects.Implements org. Builds a |
| public static < type of the left and right object. T> DiffBuilder. | |
| pack-priv T | |
| pack-priv T |
| diffs | back to summary |
|---|---|
| private final List<Diff<?>> diffs | |
| equals | back to summary |
|---|---|
| private final boolean equals | |
| left | back to summary |
|---|---|
| private final T left | |
| right | back to summary |
|---|---|
| private final T right | |
| style | back to summary |
|---|---|
| private final ToStringStyle style | |
| TO_STRING_FORMAT | back to summary |
|---|---|
| pack-priv static final String TO_STRING_FORMAT | |
| toStringFormat | back to summary |
|---|---|
| private final String toStringFormat | |
| DiffBuilder | back to summary |
|---|---|
| public DiffBuilder(final T left, final T right, final ToStringStyle style)
Deprecated Use Constructs a builder for the specified objects with the specified style.
If
This delegates to
| |
| DiffBuilder | back to summary |
|---|---|
| public DiffBuilder(final T left, final T right, final ToStringStyle style, final boolean testObjectsEquals)
Deprecated Use Constructs a builder for the specified objects with the specified style.
If
| |
| DiffBuilder | back to summary |
|---|---|
| private DiffBuilder(final T left, final T right, final ToStringStyle style, final boolean testObjectsEquals, final String toStringFormat) | |
| add | back to summary |
|---|---|
| private <F> DiffBuilder | |
| append | back to summary |
|---|---|
| public DiffBuilder Tests if two
| |
| append | back to summary |
|---|---|
| public DiffBuilder Tests if two
| |
| append | back to summary |
|---|---|
| public DiffBuilder Tests if two
| |
| append | back to summary |
|---|---|
| public DiffBuilder Tests if two
| |
| append | back to summary |
|---|---|
| public DiffBuilder Tests if two
| |
| append | back to summary |
|---|---|
| public DiffBuilder Tests if two
| |
| append | back to summary |
|---|---|
| public DiffBuilder Appends diffs from another Useful this method to compare properties which are themselves Diffable and would like to know which specific part of it is different.
| |
| append | back to summary |
|---|---|
| public DiffBuilder Tests if two
| |
| append | back to summary |
|---|---|
| public DiffBuilder Tests if two
| |
| append | back to summary |
|---|---|
| public DiffBuilder Test if two
| |
| append | back to summary |
|---|---|
| public DiffBuilder Tests if two
| |
| append | back to summary |
|---|---|
| public DiffBuilder Tests if two
| |
| append | back to summary |
|---|---|
| public DiffBuilder Tests if two
| |
| append | back to summary |
|---|---|
| public DiffBuilder Tests if two
| |
| append | back to summary |
|---|---|
| public DiffBuilder Tests if two
| |
| append | back to summary |
|---|---|
| public DiffBuilder Tests if two
| |
| append | back to summary |
|---|---|
| public DiffBuilder Tests if two
| |
| append | back to summary |
|---|---|
| public DiffBuilder Tests if two
| |
| append | back to summary |
|---|---|
| public DiffBuilder Tests if two
| |
| build | back to summary |
|---|---|
| public DiffResult Implements org. Builds a
| |
| builder | back to summary |
|---|---|
| public static <T> DiffBuilder. Constructs a new
| |
| getLeft | back to summary |
|---|---|
| pack-priv T getLeft() Gets the left object.
| |
| getRight | back to summary |
|---|---|
| pack-priv T getRight() Gets the right object.
| |
| Modifier and Type | Field and Description |
|---|---|
| private T | |
| private T | |
| private ToStringStyle | |
| private boolean | |
| private String |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public DiffBuilder | |
| public DiffBuilder. | |
| public DiffBuilder. | |
| public DiffBuilder. | Returns: this instance.the style to use when outputting the objects, style)null uses the default.Sets the style will to use when outputting the objects, |
| public DiffBuilder. | Returns: this instance.If true, this will test if lhs and rhs are the same or equal. All of the append(fieldName, left, right) methods will abort
without creating a field testObjectsEquals)Diff if the trivially equal test is enabled and returns true. The result of this test is
never changed throughout the life of this DiffBuilder.Sets whether to test if left and right are the same or equal. |
| public DiffBuilder. | Returns: this instance.null uses the default.Sets the two-argument format string for |
| left | back to summary |
|---|---|
| private T left | |
| right | back to summary |
|---|---|
| private T right | |
| style | back to summary |
|---|---|
| private ToStringStyle style | |
| testObjectsEquals | back to summary |
|---|---|
| private boolean testObjectsEquals | |
| toStringFormat | back to summary |
|---|---|
| private String toStringFormat | |
| Builder | back to summary |
|---|---|
| public Builder() Constructs a new instance. | |
| build | back to summary |
|---|---|
| public DiffBuilder Builds a new configured
| |
| setLeft | back to summary |
|---|---|
| public DiffBuilder. Sets the left object.
| |
| setRight | back to summary |
|---|---|
| public DiffBuilder. Sets the right object.
| |
| setStyle | back to summary |
|---|---|
| public DiffBuilder. Sets the style will to use when outputting the objects,
| |
| setTestObjectsEquals | back to summary |
|---|---|
| public DiffBuilder. Sets whether to test if left and right are the same or equal. All of the append(fieldName, left, right) methods will abort without creating a field
| |
| setToStringFormat | back to summary |
|---|---|
| public DiffBuilder. Sets the two-argument format string for
| |
| Modifier and Type | Field and Description |
|---|---|
| private final DiffBuilder. | |
| private final DiffBuilder. | |
| private static final long |
| Access | Constructor and Description |
|---|---|
| private | SDiff(final String fieldName, final DiffBuilder.
|
| Modifier and Type | Method and Description |
|---|---|
| public T | getLeft()
Implements abstract org. Gets the left element from this pair. |
| public T | getRight()
Implements abstract org. Gets the right element from this pair. |
| leftSupplier | back to summary |
|---|---|
| private final DiffBuilder. | |
| rightSupplier | back to summary |
|---|---|
| private final DiffBuilder. | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides org. | |
| SDiff | back to summary |
|---|---|
| private SDiff(final String fieldName, final DiffBuilder. | |
| getLeft | back to summary |
|---|---|
| public T getLeft() Implements abstract org. Doc from org. Gets the left element from this pair. When treated as a key-value pair, this is the key.
| |
| getRight | back to summary |
|---|---|
| public T getRight() Implements abstract org. Doc from org. Gets the right element from this pair. When treated as a key-value pair, this is the value.
| |