java.lang.Object
org.eclipse.core.databinding.observable.Diffs

public class Diffs extends Object
Since:
1.0
  • Constructor Details

    • Diffs

      public Diffs()
  • Method Details

    • 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 a ListDiff<? extends E> into a ListDiff<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 a SetDiff<? extends E> into a SetDiff<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 a MapDiff<? extends K, ? extends V> into a MapDiff<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 a ValueDiff<? extends V> into a ValueDiff<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 a ListDiff describing the change between the specified old and new list states.
      Type Parameters:
      E - the list element type
      Parameters:
      oldList - the old list state
      newList - 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 computed ListDiff describing the change between the specified old and new list states.
      Type Parameters:
      E - the list element type
      Parameters:
      oldList - the old list state
      newList - 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.
      Checks whether the two objects are null -- allowing for null.
      Parameters:
      left - The left object to compare; may be null.
      right - The right object to compare; may be null.
      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 a SetDiff describing the change between the specified old and new set states.
      Type Parameters:
      E - the set element type
      Parameters:
      oldSet - the old set state
      newSet - 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 computed SetDiff describing the change between the specified old and new set states.
      Type Parameters:
      E - the set element type
      Parameters:
      oldSet - the old set state
      newSet - 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 a MapDiff describing the change between the specified old and new map states.
      Type Parameters:
      K - the type of keys maintained by this map
      V - the type of mapped values
      Parameters:
      oldMap - the old map state
      newMap - 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 computed MapDiff describing the change between the specified old and new map states.
      Type Parameters:
      K - the type of keys maintained by this map
      V - the type of mapped values
      Parameters:
      oldMap - the old map state
      newMap - 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 value
      newValue - 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 elements
      removals - 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 element
      difference2 - 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 changed
      isAddition - true if element is added or false if removed
      element - 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 map
      V - the type of mapped values
      Parameters:
      addedKey - key added to map
      newValue - 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 map
      V - the type of mapped values
      Parameters:
      existingKey - key of the changed element
      oldValue - old value for key
      newValue - 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 map
      V - the type of mapped values
      Parameters:
      removedKey - key removed from map
      oldValue - 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 map
      V - 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 map
      V - the type of mapped values
      Parameters:
      addedKeys - the keys added to map
      removedKeys - the keys removed from map
      changedKeys - the keys with changed values
      oldValues - map of removed key values and old values of changed keys
      newValues - map of added key values and new values of changed keys
      Returns:
      a map diff