public class StorageMap extends AbstractMap<String,String>
Storage
as a standard Map<String, String>
.
Experimental API: This API is still under development and is subject to change.
The following characteristics are associated with this Map:
put(String, String)
,
AbstractMap.putAll(Map)
, remove(Object)
, clear()
,
Entry#setValue(Object)
) operate as intended;AbstractMap.keySet()
, entrySet()
and AbstractMap.values()
)
operate as intended;null
values and keys - The Storage doesn't
accept keys or values which are null
;AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Constructor and Description |
---|
StorageMap(Storage storage)
Creates the Map with the specified Storage as data provider.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all items from the Storage.
|
boolean |
containsKey(Object key)
Returns
true if the Storage contains the specified key,
false otherwise. |
boolean |
containsValue(Object value)
Returns
true if the Storage contains the specified value,
false otherwise (or if the specified key is null
). |
Set<Map.Entry<String,String>> |
entrySet()
Returns a Set containing all entries of the Storage.
|
String |
get(Object key)
Returns the value associated with the specified key in the Storage.
|
String |
put(String key,
String value)
Adds (or overwrites) a new key/value pair in the Storage.
|
String |
remove(Object key)
Removes the key/value pair from the Storage.
|
int |
size()
Returns the number of items in the Storage.
|
equals, hashCode, isEmpty, keySet, putAll, toString, values
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
public StorageMap(Storage storage)
storage
- a local/session Storage instance obtained by either
Storage.getLocalStorageIfSupported()
or
Storage.getSessionStorageIfSupported()
.public void clear()
clear
in interface Map<String,String>
clear
in class AbstractMap<String,String>
Storage.clear()
public boolean containsKey(Object key)
true
if the Storage contains the specified key,
false
otherwise.containsKey
in interface Map<String,String>
containsKey
in class AbstractMap<String,String>
public boolean containsValue(Object value)
true
if the Storage contains the specified value,
false
otherwise (or if the specified key is null
).containsValue
in interface Map<String,String>
containsValue
in class AbstractMap<String,String>
public Set<Map.Entry<String,String>> entrySet()
public String get(Object key)
get
in interface Map<String,String>
get
in class AbstractMap<String,String>
key
- the key identifying the valueStorage.getItem(String)
public String put(String key, String value)
put
in interface Map<String,String>
put
in class AbstractMap<String,String>
key
- the key identifying the value (not null
)value
- the value associated with the key (not null
)Storage.setItem(String, String)
public String remove(Object key)
remove
in interface Map<String,String>
remove
in class AbstractMap<String,String>
key
- the key identifying the item to removenull
if the key
was not present in the StorageStorage.removeItem(String)
public int size()
size
in interface Map<String,String>
size
in class AbstractMap<String,String>
Storage.getLength()
Copyright © 2018. All rights reserved.