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
Base map model implementation.
-
Nested Class Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addMapListener
(IMapListener<K, V> listener) Adds the map listener.void
clear()
boolean
containsKey
(Object key) boolean
containsValue
(Object value) void
discard()
Discards the changes stored in the model buffer since lastIModel.commit()
operation.entrySet()
void
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.protected boolean
isElementEqual
(V e1, V e2) Checks the equality of the two values of the map.boolean
isEmpty()
boolean
Checks the map for equality with the current stored map.keySet()
protected final void
notifyMapChanged
(ChangeOrigin changeOrigin) Notifies the listeners about a change of this map.void
protected final void
Queues the runnable that notifies the listeners about a change of this map.void
removeMapListener
(IMapListener<K, V> listener) Removes the map listener.protected final void
setCommittedMap
(Map<K, V> map) Sets the committed with the new value.protected final void
Makes copies of the given map and sets both committed and uncommitted maps at the same time.protected final void
setUncommitedMap
(Map<K, V> map) Sets the uncommitted with the new value.int
size()
toString()
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
-
Constructor Details
-
MapModel
public MapModel()
-
-
Method Details
-
addMapListener
Description copied from interface:IMap
Adds the map listener.- Specified by:
addMapListener
in interfaceIMap<K,
V> - Parameters:
listener
- the listener to add.
-
removeMapListener
Description copied from interface:IMap
Removes the map listener.- Specified by:
removeMapListener
in interfaceIMap<K,
V> - Parameters:
listener
- the listener to add.
-
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
Description copied from interface:IMap
Checks the map for equality with the current stored map. -
size
public int size() -
isEmpty
public boolean isEmpty() -
containsKey
- Specified by:
containsKey
in interfaceMap<K,
V>
-
containsValue
- Specified by:
containsValue
in interfaceMap<K,
V>
-
get
-
put
-
remove
-
putAll
-
clear
public void clear() -
keySet
-
values
-
entrySet
-
fill
Description copied from interface:IMap
Clears the current stored map and adds all elements of the given map to the stored one. -
toString
-
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
- Returns:
- the committed list, under normal conditions it should be in sync with data source.
-
getUncommittedMap
- Returns:
- the buffered but yet uncommitted list.
-
setCommittedMap
Sets the committed with the new value.- Parameters:
map
- the new committed map to set.
-
setUncommitedMap
Sets the uncommitted with the new value.- Parameters:
map
- the new uncommitted map to set.
-
setMap
Makes copies of the given map and sets both committed and uncommitted maps at the same time.- Parameters:
map
- the map to set.
-
notifyMapChanged
Notifies the listeners about a change of this map. -
isElementEqual
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
Returns the newly created map from entry collection.- Parameters:
collection
- the collection of map entries.- Returns:
- the map
-