Class MapDiff<K,​V>

  • Type Parameters:
    K - Type of the map's keys.
    V - Type of the map's values.
    All Implemented Interfaces:
    IMapDiff<K,​V>, Serializable

    public class MapDiff<K,​V>
    extends Object
    implements IMapDiff<K,​V>
    Implementation of IMapDiff with a static method for creating a diff between two Maps.
    Since:
    7.0.0
    Author:
    XIMA MEDIA GmbH
    See Also:
    Serialized Form
    • Method Detail

      • applyBackward

        public void applyBackward​(Map<K,​V> map)
        Description copied from interface: IMapDiff
        Applies the diff represented by this instance to the given map. If this is called on the map new map used to create the diff, this method turns it into the old map.
        Specified by:
        applyBackward in interface IMapDiff<K,​V>
        Parameters:
        map - Map to modify.
      • applyForward

        public void applyForward​(Map<K,​V> map)
        Description copied from interface: IMapDiff
        Applies the diff represented by this instance to the given map. If this is called on the map old map used to create the diff, this method turns it into the new map.
        Specified by:
        applyForward in interface IMapDiff<K,​V>
        Parameters:
        map - Map to modify.
      • getAddedEntries

        public Map<K,​V> getAddedEntries()
        Specified by:
        getAddedEntries in interface IMapDiff<K,​V>
        Returns:
        A map with the keys of the newly added entries, and the new value for each key.
      • getRemovedEntries

        public Map<K,​V> getRemovedEntries()
        Specified by:
        getRemovedEntries in interface IMapDiff<K,​V>
        Returns:
        A map with the keys of the removed entries, and the old value for each key.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • betweenMaps

        public static <K,​V> IMapDiff<K,​V> betweenMaps​(Map<K,​V> oldMap,
                                                                  Map<K,​V> newMap)
        Computes and returns the difference between two Maps.
        Type Parameters:
        K - Type of the map's keys.
        V - Type of the map's values.
        Parameters:
        oldMap - Previous map.
        newMap - New map.
        Returns:
        The diff between the two maps.
      • empty

        public static IMapDiff<String,​Serializable> empty()
        Returns:
        A diff with no entries (no added, removed, or modified entries).