T - U - public abstract class Delta<T,U>
extends java.lang.Object
ChangedItem, Maps and lists procude MapDelta and ListDelta
and plain arrays produce ArrayDelta.
Note that maps could be effectively compared only if use same key types. For maps, lists and arrays removed, added
and changed keys are detected separately, using CreatedItem, RemovedItem. Changed items could be any
Delta inherited instances.
Comaring is made in terms of the value being changed, from old value to new value.
To perform deep compare use between(Object, Object) method.
This is an abstract base class which is a root for implementations describing different types of differences ;)
| Constructor and Description |
|---|
Delta(Delta parent,
T oldValue,
U newValue) |
| Modifier and Type | Method and Description |
|---|---|
static <T,U,D extends Delta> |
between(T oldValue,
U newValue)
Deply compare two objects and calculate the difference.
|
java.util.List<Delta> |
getNestedDelta() |
Delta |
getParent() |
abstract boolean |
isEmpty() |
U |
newValue() |
T |
oldValue() |
protected void |
registerInParent()
Subclasses must call it after the difference item is completely constructed and
isEmpty() return valid
result. |
protected void registerInParent()
isEmpty() return valid
result. This method builds parent-child tree of Delta instances, excluding empty ones.public Delta getParent()
public static <T,U,D extends Delta> D between(T oldValue, U newValue)
MapDelta, ListDelta, ArrayDelta ioe ChangedItem will be returned. Deep diff traverse structures of Map, List and primitive java arrays. Difference in collection is showb with ChangedItem, CreatedItem and RemovedItem. Note that Map instances should use the same key type (for example, String)
to properly calculate the delta.
We use "old" and "new" item terminology for clarity, actually, if can compare any 2 objects.T - U - D - oldValue - first value to comparenewValue - second value to comparepublic T oldValue()
public U newValue()
public abstract boolean isEmpty()
public java.util.List<Delta> getNestedDelta()