Class ListDiff<E>
java.lang.Object
org.eclipse.core.databinding.observable.list.ListDiff<E>
- Type Parameters:
E
- the type of the elements in this diff
- All Implemented Interfaces:
IDiff
Object describing a diff between two lists.
- Since:
- 1.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(ListDiffVisitor<? super E> visitor) Traverses thegetDifferences()
array, calling the appropriate method invisitor
for each difference.void
Applies the changes in this diff to the given listabstract ListDiffEntry<E>[]
Returns a ListDiffEntry array representing the differences in the list, in the order they are to be processed.boolean
isEmpty()
Returns true if the diff contains no added, removed, moved or replaced elements.simulateOn
(List<E> list) Returns a list showing whatlist
would look like if this diff were applied to it.toString()
-
Constructor Details
-
ListDiff
public ListDiff()
-
-
Method Details
-
getDifferences
Returns a ListDiffEntry array representing the differences in the list, in the order they are to be processed.This method returns identical results to
getDifferencesAsList
except that the results are returned as a array and so the ListDiffEntry objects are not properly typed. This form is here for compatibility. UsegetDifferencesAsList
to get typed results.- Returns:
- a ListDiffEntry array representing the differences in the list, in the order they are to be processed.
-
accept
Traverses thegetDifferences()
array, calling the appropriate method invisitor
for each difference.ListDiffVisitor.handleReplace(int, Object, Object)
is called whenever an add entry is adjacent to a remove entry, and both entries operate on the same location in the list.ListDiffVisitor.handleMove(int, int, Object)
is called whenever an add entry is adjacent to a remove entry, and both entries have equivalent elements.ListDiffVisitor.handleRemove(int, Object)
is called whenever a remove entry does not match conditions 1 or 2.ListDiffVisitor.handleAdd(int, Object)
is called whenever an add entry does not match conditions in 1 or 2.
- Parameters:
visitor
- the visitor to receive callbacks.- Since:
- 1.1
- See Also:
-
isEmpty
public boolean isEmpty()Returns true if the diff contains no added, removed, moved or replaced elements.- Returns:
- true if the diff contains no added, removed, moved or replaced elements.
- Since:
- 1.2
-
applyTo
Applies the changes in this diff to the given list- Parameters:
list
- the list to which the diff will be applied- Since:
- 1.2
-
simulateOn
Returns a list showing whatlist
would look like if this diff were applied to it.Note: the returned list is only valid until structural changes are made to the passed-in list.
- Parameters:
list
- the list over which the diff will be simulated- Returns:
- an unmodifiable list showing what
list
would look like if it were passed to theapplyTo(List)
method. - Since:
- 1.3
- See Also:
-
toString
-