K
- the type of keys in this mapV
- the type of values in this mappublic final class MapIndexProxy<K,V> extends AbstractNativeProxy implements MapIndex<K,V>
The map implementation does not permit null keys and values.
The "destructive" methods of the map, i.e., the one that change the map contents,
are specified to throw UnsupportedOperationException
if
the map has been created with a read-only database view.
All method arguments are non-null by default.
This class is not thread-safe and its instances shall not be shared between threads.
When the view goes out of scope, this map is destroyed. Subsequent use of the closed map
is prohibited and will result in IllegalStateException
.
View
nativeHandle
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all of the key-value pairs from the map.
|
boolean |
containsKey(K key)
Returns true if this map contains a mapping for the specified key.
|
java.util.Iterator<MapEntry<K,V>> |
entries()
Returns an iterator over the map entries.
|
V |
get(K key)
Returns the value associated with the specified key,
or
null if there is no mapping for the key. |
java.lang.String |
getName()
Returns the name of this index.
|
java.lang.String |
getName()
Returns the name of this index.
|
java.util.Iterator<K> |
keys()
Returns an iterator over the map keys in lexicographical order.
|
static <K,V> MapIndexProxy<K,V> |
newInGroupUnsafe(java.lang.String groupName,
byte[] mapId,
View view,
Serializer<K> keySerializer,
Serializer<V> valueSerializer)
Creates a new map in a collection group
with the given name.
|
static <K,V> MapIndexProxy<K,V> |
newInstance(java.lang.String name,
View view,
Serializer<K> keySerializer,
Serializer<V> valueSerializer)
Creates a new MapIndexProxy.
|
void |
put(K key,
V value)
Puts a new key-value pair into the map.
|
void |
putAll(java.util.Map<? extends K,? extends V> sourceMap)
Puts all key-value pairs from the given map into this map.
|
void |
remove(K key)
Removes the value mapped to the specified key from the map.
|
java.lang.String |
toString() |
java.util.Iterator<V> |
values()
Returns an iterator over the map values in lexicographical order of keys.
|
getNativeHandle, isValidHandle
public static <K,V> MapIndexProxy<K,V> newInstance(java.lang.String name, View view, Serializer<K> keySerializer, Serializer<V> valueSerializer)
K
- the type of keys in the mapV
- the type of values in the mapname
- a unique alphanumeric non-empty identifier of this map in the underlying storage:
[a-zA-Z0-9_]view
- a database view. Must be valid.
If a view is read-only, "destructive" operations are not permitted.keySerializer
- a serializer of keysvalueSerializer
- a serializer of valuesjava.lang.IllegalStateException
- if the view is not validjava.lang.IllegalArgumentException
- if the name is emptypublic static <K,V> MapIndexProxy<K,V> newInGroupUnsafe(java.lang.String groupName, byte[] mapId, View view, Serializer<K> keySerializer, Serializer<V> valueSerializer)
See a caveat on index identifiers.
K
- the type of keys in the mapV
- the type of values in the mapgroupName
- a name of the collection groupmapId
- an identifier of this collection in the group, see the caveatsview
- a database viewkeySerializer
- a serializer of keysvalueSerializer
- a serializer of valuesjava.lang.IllegalStateException
- if the view is not validjava.lang.IllegalArgumentException
- if the name or index id is emptypublic boolean containsKey(K key)
MapIndex
containsKey
in interface MapIndex<K,V>
public void put(K key, V value)
MapIndex
public void putAll(java.util.Map<? extends K,? extends V> sourceMap)
MapIndex
MapIndex.put(K, V)
operations.public V get(K key)
MapIndex
null
if there is no mapping for the key.public void remove(K key)
MapIndex
public java.util.Iterator<K> keys()
MapIndex
Any destructive operation on the same Fork
this map uses
(but not necessarily on this map) will invalidate the iterator.
public java.util.Iterator<V> values()
MapIndex
Any destructive operation on the same Fork
this map uses
(but not necessarily on this map) will invalidate the iterator.
public java.util.Iterator<MapEntry<K,V>> entries()
MapIndex
Any destructive operation on the same Fork
this map uses
(but not necessarily on this map) will invalidate the iterator.
public void clear()
MapIndex
public java.lang.String getName()
public final java.lang.String getName()
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2018 Exonum. All rights reserved.