Class ChangeTrackingMap<T extends Serializable>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<T,ChangeType>
-
- de.aristaflow.adept2.model.common.changetracking.ChangeTrackingMap<T>
-
- 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 normalHashMap
by the means to track and combine changes for property values. Depending on the type of property value (and therefore the usedChangeCombiner
), several changes of the same property value are combined to form one change.- Author:
- Ulrich Kreher
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Field Summary
Fields Modifier and Type Field Description protected ChangeCombiner
changeCombiner
The change combiner used for combining several changes to a property value.
-
Constructor Summary
Constructors Constructor Description ChangeTrackingMap(ChangeCombiner changeCombiner)
Creates a newChangeTrackingMap
with the designated change combiner.ChangeTrackingMap(ChangeCombiner changeCombiner, int initialCapacity)
Creates a newChangeTrackingMap
with the designated change combiner and the designated initial capacity.ChangeTrackingMap(ChangeCombiner changeCombiner, Map<? extends T,ChangeType> m)
Creates a newChangeTrackingMap
with the designated change combiner containing the content of the designated map.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.-
Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
-
-
-
-
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 newChangeTrackingMap
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 newChangeTrackingMap
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 theHashMap
.
-
ChangeTrackingMap
public ChangeTrackingMap(ChangeCombiner changeCombiner, Map<? extends T,ChangeType> m)
Creates a newChangeTrackingMap
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.
-
-