K
- the type of keys of this mapV
- the type of values of this mappublic abstract class SafeMap<K,V> extends Object implements Iterable<Map.Entry<K,V>>
Constructor and Description |
---|
SafeMap() |
Modifier and Type | Method and Description |
---|---|
SafeMap<K,V> |
clear()
Clears the entire map.
|
boolean |
containsKey(K key)
Determines if the map contains the given key.
|
Map<K,V> |
copyMap()
Creates a copy of the underlying map.
|
protected abstract V |
copyValue(V value)
Creates a copy of the given value.
|
Map<K,V> |
data()
Provides readonly access to the underlying map.
|
boolean |
equals(Object obj) |
void |
forEach(Consumer<? super Map.Entry<K,V>> action) |
Optional<V> |
get(K key)
Returns the value stored for the given key.
|
int |
hashCode() |
boolean |
isEmpty()
Determines if the map is empty.
|
boolean |
isFilled()
Determines if the map is not empty.
|
Iterator<Map.Entry<K,V>> |
iterator() |
Map<K,V> |
modify()
Provides read and write access to the underlying map.
|
Map<K,V> |
original()
Provides access to the map which was origrinally used to supply contents.
|
SafeMap<K,V> |
put(K key,
V value)
Puts the given key and value into the map.
|
void |
setData(Map<K,V> newData)
Sets the underyling map to use.
|
int |
size()
Returns the number of entries in the map.
|
Spliterator<Map.Entry<K,V>> |
spliterator() |
protected abstract boolean |
valueNeedsCopy()
Determines if values in this map must be copied if the map is copied.
|
public Map<K,V> data()
public Map<K,V> modify()
public SafeMap<K,V> put(K key, V value)
key
- the key used to store the valuevalue
- the value to storepublic Optional<V> get(K key)
key
- the key used to lookup the valuepublic SafeMap<K,V> clear()
public Map<K,V> copyMap()
This is used by the framework to permit change tracking. If we wouldn't create a copy of the map, the "original" backup and the map in the entity would be the same and therefore no modifications would be recognized.
protected abstract boolean valueNeedsCopy()
protected abstract V copyValue(V value)
value
- the value to copypublic Map<K,V> original()
In contrast to modify()
this will not create a new map if none is present yet.
Therefore the result might be readonly. The is mainly used by the storage engine to
re-use internal data structures as much as possible.
public void setData(Map<K,V> newData)
As original()
this should only be used by the storage engine to insert a database specific
implementation which can later be re-used.
newData
- the new map to usepublic int size()
public boolean isEmpty()
public boolean isFilled()
public boolean containsKey(K key)
key
- the key to check forpublic Spliterator<Map.Entry<K,V>> spliterator()
spliterator
in interface Iterable<Map.Entry<K,V>>
Copyright © 2018. All rights reserved.