Package com._1c.g5.aef2.models.map
Class MapModel<K,V>
- java.lang.Object
-
- com._1c.g5.aef2.validators.Validable
-
- com._1c.g5.aef2.models.Model
-
- com._1c.g5.aef2.models.EditableModel
-
- com._1c.g5.aef2.models.map.MapModel<K,V>
-
- All Implemented Interfaces:
IEditableModel
,IModel
,IMap<K,V>
,IValidable
,Map<K,V>
- Direct Known Subclasses:
BmMap
,EmfMap
,MapWorkingCopy
,PojoMap
public abstract class MapModel<K,V> extends EditableModel implements IMap<K,V>
Base map model implementation.
-
-
Constructor Summary
Constructors Constructor Description MapModel()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMapListener(IMapListener<K,V> listener)
Adds the map listener.void
clear()
boolean
containsKey(Object key)
boolean
containsValue(Object value)
IMap<K,V>
createWorkingCopy()
void
discard()
Discards the changes stored in the model buffer since lastIModel.commit()
operation.Set<Map.Entry<K,V>>
entrySet()
void
fill(Map<? extends K,? extends V> map)
Clears the current stored map and adds all elements of the given map to the stored one.static <K,V>
Map<K,V>fromCollection(Collection<Map.Entry<K,V>> collection)
Returns the newly created map from entry collection.V
get(Object key)
protected Map<K,V>
getCommittedMap()
protected Map<K,V>
getUncommittedMap()
protected boolean
isElementEqual(V e1, V e2)
Checks the equality of the two values of the map.boolean
isEmpty()
boolean
isEqual(Map<K,V> other)
Checks the map for equality with the current stored map.Set<K>
keySet()
protected void
notifyMapChanged(ChangeOrigin changeOrigin)
Notifies the listeners about a change of this map.V
put(K key, V value)
void
putAll(Map<? extends K,? extends V> m)
protected void
queueNotifyMapChanged()
Queues the runnable that notifies the listeners about a change of this map.V
remove(Object key)
void
removeMapListener(IMapListener<K,V> listener)
Removes the map listener.protected void
setCommittedMap(Map<K,V> map)
Sets the committed with the new value.protected void
setMap(Map<K,V> map)
Makes copies of the given map and sets both committed and uncommitted maps at the same time.protected void
setUncommitedMap(Map<K,V> map)
Sets the uncommitted with the new value.int
size()
String
toString()
Collection<V>
values()
-
Methods inherited from class com._1c.g5.aef2.models.EditableModel
isEditable, setEditable
-
Methods inherited from class com._1c.g5.aef2.models.Model
addModelListener, beginExternalUpdate, checkOffline, checkOnline, commit, dispose, endExternalUpdate, getComponent, getCurrentChangeOrigin, getRunnableQueue, isOnline, notifyModelChanged, notifyModelCommitted, removeModelListener, setComponent, setOnline
-
Methods inherited from class com._1c.g5.aef2.validators.Validable
addValidator, getValidatorTarget, removeValidator, validate, validate
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com._1c.g5.aef2.models.IModel
addModelListener, commit, dispose, getChange, getComponent, isOnline, removeModelListener, setComponent
-
Methods inherited from interface com._1c.g5.aef2.validators.IValidable
addValidator, removeValidator, validate, validate
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Method Detail
-
addMapListener
public void addMapListener(IMapListener<K,V> listener)
Description copied from interface:IMap
Adds the map listener.- Specified by:
addMapListener
in interfaceIMap<K,V>
- Parameters:
listener
- the listener to add.
-
removeMapListener
public void removeMapListener(IMapListener<K,V> listener)
Description copied from interface:IMap
Removes the map listener.- Specified by:
removeMapListener
in interfaceIMap<K,V>
- Parameters:
listener
- the listener to add.
-
createWorkingCopy
public IMap<K,V> createWorkingCopy()
- Specified by:
createWorkingCopy
in interfaceIMap<K,V>
- Specified by:
createWorkingCopy
in interfaceIModel
- Overrides:
createWorkingCopy
in classModel
- Returns:
- the model working copy or
null
if working copies is not supported by the model.
-
discard
public void discard()
Description copied from interface:IModel
Discards the changes stored in the model buffer since lastIModel.commit()
operation.
-
isEqual
public boolean isEqual(Map<K,V> other)
Description copied from interface:IMap
Checks the map for equality with the current stored map.
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKey
in interfaceMap<K,V>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValue
in interfaceMap<K,V>
-
fill
public void fill(Map<? extends K,? extends V> map)
Description copied from interface:IMap
Clears the current stored map and adds all elements of the given map to the stored one.
-
queueNotifyMapChanged
protected final void queueNotifyMapChanged()
Queues the runnable that notifies the listeners about a change of this map. In fact it queues a runnable that performsnotifyMapChanged(ChangeOrigin)
.
-
getCommittedMap
protected final Map<K,V> getCommittedMap()
- Returns:
- the committed list, under normal conditions it should be in sync with data source.
-
getUncommittedMap
protected final Map<K,V> getUncommittedMap()
- Returns:
- the buffered but yet uncommitted list.
-
setCommittedMap
protected final void setCommittedMap(Map<K,V> map)
Sets the committed with the new value.- Parameters:
map
- the new committed map to set.
-
setUncommitedMap
protected final void setUncommitedMap(Map<K,V> map)
Sets the uncommitted with the new value.- Parameters:
map
- the new uncommitted map to set.
-
setMap
protected final void setMap(Map<K,V> map)
Makes copies of the given map and sets both committed and uncommitted maps at the same time.- Parameters:
map
- the map to set.
-
notifyMapChanged
protected final void notifyMapChanged(ChangeOrigin changeOrigin)
Notifies the listeners about a change of this map.
-
isElementEqual
protected boolean isElementEqual(V e1, V e2)
Checks the equality of the two values of the map.- Parameters:
e1
- the first valuee2
- the second value- Returns:
true
if the values are equals, otherwise -false
.
-
fromCollection
public static <K,V> Map<K,V> fromCollection(Collection<Map.Entry<K,V>> collection)
Returns the newly created map from entry collection.- Parameters:
collection
- the collection of map entries.- Returns:
- the map
-
-