Class ChangeTrackingMap<T extends Serializable>

  • Type Parameters:
    T - The type of the property values that are changed.
    All Implemented Interfaces:
    Serializable, Cloneable, Map<T,​ChangeType>

    public class ChangeTrackingMap<T extends Serializable>
    extends HashMap<T,​ChangeType>
    This map extends a normal HashMap by the means to track and combine changes for property values. Depending on the type of property value (and therefore the used ChangeCombiner), several changes of the same property value are combined to form one change.
    Author:
    Ulrich Kreher
    See Also:
    Serialized Form
    • Field Detail

      • changeCombiner

        protected final ChangeCombiner changeCombiner
        The change combiner used for combining several changes to a property value.
    • Constructor Detail

      • ChangeTrackingMap

        public ChangeTrackingMap​(ChangeCombiner changeCombiner)
        Creates a new ChangeTrackingMap with the designated change combiner.
        Parameters:
        changeCombiner - The change combiner used for combining several changes to a property value.
      • ChangeTrackingMap

        public ChangeTrackingMap​(ChangeCombiner changeCombiner,
                                 int initialCapacity)
        Creates a new ChangeTrackingMap with the designated change combiner and the designated initial capacity.
        Parameters:
        changeCombiner - The change combiner used for combining several changes to a property value.
        initialCapacity - The initial capacity for the HashMap.
      • ChangeTrackingMap

        public ChangeTrackingMap​(ChangeCombiner changeCombiner,
                                 Map<? extends T,​ChangeType> m)
        Creates a new ChangeTrackingMap with the designated change combiner containing the content of the designated map.
        Parameters:
        changeCombiner - The change combiner used for combining several changes to a property value.
        m - The map of which the mappings are to be placed in this map.
    • Method Detail

      • change

        public ChangeType change​(T propertyValue,
                                 ChangeType changeType)
        Tracks a change of the designated type for the designated property value and combines the change with an existing one.
        Parameters:
        propertyValue - The value of the property that has changed.
        changeType - The type of the change of the property.
        Returns:
        The change type as combination of the previous and the current change.