Class Diffs
- java.lang.Object
-
- org.eclipse.core.databinding.observable.Diffs
-
public class Diffs extends Object
- Since:
- 1.0
-
-
Constructor Summary
Constructors Constructor Description Diffs()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <E> ListDiff<E>
computeLazyListDiff(List<? extends E> oldList, List<? extends E> newList)
Returns a lazily computedListDiff
describing the change between the specified old and new list states.static <K,V>
MapDiff<K,V>computeLazyMapDiff(Map<? extends K,? extends V> oldMap, Map<? extends K,? extends V> newMap)
Returns a lazily computedMapDiff
describing the change between the specified old and new map states.static <E> SetDiff<E>
computeLazySetDiff(Set<? extends E> oldSet, Set<? extends E> newSet)
Returns a lazily computedSetDiff
describing the change between the specified old and new set states.static <E> ListDiff<E>
computeListDiff(List<? extends E> oldList, List<? extends E> newList)
Returns aListDiff
describing the change between the specified old and new list states.static <K,V>
MapDiff<K,V>computeMapDiff(Map<? extends K,? extends V> oldMap, Map<? extends K,? extends V> newMap)
Returns aMapDiff
describing the change between the specified old and new map states.static <E> SetDiff<E>
computeSetDiff(Set<? extends E> oldSet, Set<? extends E> newSet)
Returns aSetDiff
describing the change between the specified old and new set states.static <E> ListDiff<E>
createListDiff(List<ListDiffEntry<E>> differences)
Creates a new ListDiff object given its constituent ListDiffEntry objects.static <E> ListDiff<E>
createListDiff(ListDiffEntry<E> difference)
static <E> ListDiff<E>
createListDiff(ListDiffEntry<E>... differences)
Creates a new ListDiff object given its constituent ListDiffEntry objects.static <E> ListDiff<E>
createListDiff(ListDiffEntry<E> difference1, ListDiffEntry<E> difference2)
static <E> ListDiffEntry<E>
createListDiffEntry(int position, boolean isAddition, E element)
static <K,V>
MapDiff<K,V>createMapDiff(Set<? extends K> addedKeys, Set<? extends K> removedKeys, Set<? extends K> changedKeys, Map<? extends K,? extends V> oldValues, Map<? extends K,? extends V> newValues)
static <K,V>
MapDiff<K,V>createMapDiffRemoveAll(Map<K,V> copyOfOldMap)
static <K,V>
MapDiff<K,V>createMapDiffSingleAdd(K addedKey, V newValue)
Creates a MapDiff representing the addition of a single added keystatic <K,V>
MapDiff<K,V>createMapDiffSingleChange(K existingKey, V oldValue, V newValue)
static <K,V>
MapDiff<K,V>createMapDiffSingleRemove(K removedKey, V oldValue)
static <E> SetDiff<E>
createSetDiff(Set<? extends E> additions, Set<? extends E> removals)
static <T> ValueDiff<T>
createValueDiff(T oldValue, T newValue)
Creates a diff between two valuesstatic boolean
equals(Object left, Object right)
Deprecated.UseObjects.equals(Object, Object)
insteadstatic <E> ListDiff<E>
unmodifiableDiff(ListDiff<? extends E> diff)
Returns an unmodifiable wrapper on top of the given diff.static <K,V>
MapDiff<K,V>unmodifiableDiff(MapDiff<? extends K,? extends V> diff)
Returns an unmodifiable wrapper on top of the given diff.static <E> SetDiff<E>
unmodifiableDiff(SetDiff<? extends E> diff)
Returns an unmodifiable wrapper on top of the given diff.static <V> ValueDiff<V>
unmodifiableDiff(ValueDiff<? extends V> diff)
Returns an unmodifiable wrapper on top of the given diff.
-
-
-
Method Detail
-
unmodifiableDiff
public static <E> ListDiff<E> unmodifiableDiff(ListDiff<? extends E> diff)
Returns an unmodifiable wrapper on top of the given diff. The returned diff will suppress any attempt to modify the collections it returns. Diffs are normally unmodifiable anyway, so this method is mainly used as a type-safe way to convert aListDiff<? extends E>
into aListDiff<E>
.- Parameters:
diff
- the diff to convert- Returns:
- an unmodifiable wrapper on top of the given diff
- Since:
- 1.6
-
unmodifiableDiff
public static <E> SetDiff<E> unmodifiableDiff(SetDiff<? extends E> diff)
Returns an unmodifiable wrapper on top of the given diff. The returned diff will suppress any attempt to modify the collections it returns. Diffs are normally unmodifiable anyway, so this method is mainly used as a type-safe way to convert aSetDiff<? extends E>
into aSetDiff<E>
.- Parameters:
diff
- the diff to convert- Returns:
- an unmodifiable wrapper on top of the given diff
- Since:
- 1.6
-
unmodifiableDiff
public static <K,V> MapDiff<K,V> unmodifiableDiff(MapDiff<? extends K,? extends V> diff)
Returns an unmodifiable wrapper on top of the given diff. The returned diff will suppress any attempt to modify the collections it returns. Diffs are normally unmodifiable anyway, so this method is mainly used as a type-safe way to convert aMapDiff<? extends K, ? extends V>
into aMapDiff<K,V>
.- Parameters:
diff
- the diff to convert- Returns:
- an unmodifiable wrapper on top of the given diff
- Since:
- 1.6
-
unmodifiableDiff
public static <V> ValueDiff<V> unmodifiableDiff(ValueDiff<? extends V> diff)
Returns an unmodifiable wrapper on top of the given diff. The returned diff will suppress any attempt to modify the collections it returns. Diffs are normally unmodifiable anyway, so this method is mainly used as a type-safe way to convert aValueDiff<? extends V>
into aValueDiff<V>
.- Parameters:
diff
- the diff to convert- Returns:
- an unmodifiable wrapper on top of the given diff
- Since:
- 1.6
-
computeListDiff
public static <E> ListDiff<E> computeListDiff(List<? extends E> oldList, List<? extends E> newList)
Returns aListDiff
describing the change between the specified old and new list states.- Type Parameters:
E
- the list element type- Parameters:
oldList
- the old list statenewList
- the new list state- Returns:
- the differences between oldList and newList
- Since:
- 1.6
-
computeLazyListDiff
public static <E> ListDiff<E> computeLazyListDiff(List<? extends E> oldList, List<? extends E> newList)
Returns a lazily computedListDiff
describing the change between the specified old and new list states.- Type Parameters:
E
- the list element type- Parameters:
oldList
- the old list statenewList
- the new list state- Returns:
- a lazily computed
ListDiff
describing the change between the specified old and new list states. - Since:
- 1.3
-
equals
@Deprecated public static final boolean equals(Object left, Object right)
Deprecated.UseObjects.equals(Object, Object)
insteadChecks whether the two objects arenull
-- allowing fornull
.- Parameters:
left
- The left object to compare; may benull
.right
- The right object to compare; may benull
.- Returns:
true
if the two objects are equivalent;false
otherwise.
-
computeSetDiff
public static <E> SetDiff<E> computeSetDiff(Set<? extends E> oldSet, Set<? extends E> newSet)
Returns aSetDiff
describing the change between the specified old and new set states.- Type Parameters:
E
- the set element type- Parameters:
oldSet
- the old set statenewSet
- the new set state- Returns:
- a
SetDiff
describing the change between the specified old and new set states.
-
computeLazySetDiff
public static <E> SetDiff<E> computeLazySetDiff(Set<? extends E> oldSet, Set<? extends E> newSet)
Returns a lazily computedSetDiff
describing the change between the specified old and new set states.- Type Parameters:
E
- the set element type- Parameters:
oldSet
- the old set statenewSet
- the new set state- Returns:
- a lazily computed
SetDiff
describing the change between the specified old and new set states. - Since:
- 1.3
-
computeMapDiff
public static <K,V> MapDiff<K,V> computeMapDiff(Map<? extends K,? extends V> oldMap, Map<? extends K,? extends V> newMap)
Returns aMapDiff
describing the change between the specified old and new map states.- Type Parameters:
K
- the type of keys maintained by this mapV
- the type of mapped values- Parameters:
oldMap
- the old map statenewMap
- the new map state- Returns:
- a
MapDiff
describing the change between the specified old and new map states.
-
computeLazyMapDiff
public static <K,V> MapDiff<K,V> computeLazyMapDiff(Map<? extends K,? extends V> oldMap, Map<? extends K,? extends V> newMap)
Returns a lazily computedMapDiff
describing the change between the specified old and new map states.- Type Parameters:
K
- the type of keys maintained by this mapV
- the type of mapped values- Parameters:
oldMap
- the old map statenewMap
- the new map state- Returns:
- a lazily computed
MapDiff
describing the change between the specified old and new map states. - Since:
- 1.3
-
createValueDiff
public static <T> ValueDiff<T> createValueDiff(T oldValue, T newValue)
Creates a diff between two values- Type Parameters:
T
- the value type- Parameters:
oldValue
- the old valuenewValue
- the new value- Returns:
- a value diff
-
createSetDiff
public static <E> SetDiff<E> createSetDiff(Set<? extends E> additions, Set<? extends E> removals)
- Type Parameters:
E
- the set element type- Parameters:
additions
- the added elementsremovals
- the removed elements- Returns:
- a set diff
-
createListDiff
public static <E> ListDiff<E> createListDiff(ListDiffEntry<E> difference)
- Type Parameters:
E
- the list element type- Parameters:
difference
- the entry to describe the added or removed element- Returns:
- a list diff with one differing entry
-
createListDiff
public static <E> ListDiff<E> createListDiff(ListDiffEntry<E> difference1, ListDiffEntry<E> difference2)
- Type Parameters:
E
- the list element type- Parameters:
difference1
- the first entry to describe the added or removed elementdifference2
- the second entry to describe the added or removed element- Returns:
- a list diff with two differing entries
-
createListDiff
@SafeVarargs public static <E> ListDiff<E> createListDiff(ListDiffEntry<E>... differences)
Creates a new ListDiff object given its constituent ListDiffEntry objects.This form cannot be used in a type-safe manner because it is not possible to construct an array of generic types in a type-safe manner. Use the form below which takes a properly parameterized List.
- Type Parameters:
E
- the list element type- Parameters:
differences
- a list of entries describing additions and/or removals from a list- Returns:
- a list diff with the given entries
-
createListDiff
public static <E> ListDiff<E> createListDiff(List<ListDiffEntry<E>> differences)
Creates a new ListDiff object given its constituent ListDiffEntry objects.- Type Parameters:
E
- the list element type- Parameters:
differences
- a list of entries describing additions and/or removals from a list- Returns:
- a list diff with the given entries
- Since:
- 1.6
-
createListDiffEntry
public static <E> ListDiffEntry<E> createListDiffEntry(int position, boolean isAddition, E element)
- Type Parameters:
E
- the list element type- Parameters:
position
- position where list is changedisAddition
-true
if element is added orfalse
if removedelement
- the added or removed element- Returns:
- a list diff entry
-
createMapDiffSingleAdd
public static <K,V> MapDiff<K,V> createMapDiffSingleAdd(K addedKey, V newValue)
Creates a MapDiff representing the addition of a single added key- Type Parameters:
K
- the type of keys maintained by this mapV
- the type of mapped values- Parameters:
addedKey
- key added to mapnewValue
- value of the added key- Returns:
- a map diff
-
createMapDiffSingleChange
public static <K,V> MapDiff<K,V> createMapDiffSingleChange(K existingKey, V oldValue, V newValue)
- Type Parameters:
K
- the type of keys maintained by this mapV
- the type of mapped values- Parameters:
existingKey
- key of the changed elementoldValue
- old value for keynewValue
- new value for key- Returns:
- a map diff
-
createMapDiffSingleRemove
public static <K,V> MapDiff<K,V> createMapDiffSingleRemove(K removedKey, V oldValue)
- Type Parameters:
K
- the type of keys maintained by this mapV
- the type of mapped values- Parameters:
removedKey
- key removed from mapoldValue
- value of the removed key- Returns:
- a map diff
-
createMapDiffRemoveAll
public static <K,V> MapDiff<K,V> createMapDiffRemoveAll(Map<K,V> copyOfOldMap)
- Type Parameters:
K
- the type of keys maintained by this mapV
- the type of mapped values- Parameters:
copyOfOldMap
- map content before removal- Returns:
- a map diff
-
createMapDiff
public static <K,V> MapDiff<K,V> createMapDiff(Set<? extends K> addedKeys, Set<? extends K> removedKeys, Set<? extends K> changedKeys, Map<? extends K,? extends V> oldValues, Map<? extends K,? extends V> newValues)
- Type Parameters:
K
- the type of keys maintained by this mapV
- the type of mapped values- Parameters:
addedKeys
- the keys added to mapremovedKeys
- the keys removed from mapchangedKeys
- the keys with changed valuesoldValues
- map of removed key values and old values of changed keysnewValues
- map of added key values and new values of changed keys- Returns:
- a map diff
-
-