V - serializable type of the mapped valuepublic class AbstractMemoryDataStore<V extends Serializable> extends AbstractDataStore<V>
| Modifier and Type | Field and Description |
|---|---|
protected HashMap<String,byte[]> |
keyValueMap
Data store map from the key to the value.
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractMemoryDataStore(DataStoreFactory dataStoreFactory,
String id) |
| Modifier and Type | Method and Description |
|---|---|
DataStore<V> |
clear()
Deletes all of the stored keys and values.
|
boolean |
containsKey(String key)
Returns whether the store contains the given key.
|
boolean |
containsValue(V value)
Returns whether the store contains the given value.
|
DataStore<V> |
delete(String key)
Deletes the stored key and value based on the given key, or ignored if the key doesn't already
exist.
|
V |
get(String key)
Returns the stored value for the given key or
null if not found. |
boolean |
isEmpty()
Returns whether there are any stored keys.
|
Set<String> |
keySet()
Returns the unmodifiable set of all stored keys.
|
void |
save()
Persist the key-value map into storage at the end of
set(java.lang.String, V), delete(String), and
clear(). |
DataStore<V> |
set(String key,
V value)
Stores the given value for the given key (replacing any existing value).
|
int |
size()
Returns the number of stored keys.
|
String |
toString() |
Collection<V> |
values()
Returns the unmodifiable collection of all stored values.
|
getDataStoreFactory, getIdprotected AbstractMemoryDataStore(DataStoreFactory dataStoreFactory, String id)
dataStoreFactory - data store factoryid - data store IDpublic final Set<String> keySet() throws IOException
DataStoreOrder of the keys is not specified.
IOExceptionpublic final Collection<V> values() throws IOException
DataStoreIOExceptionpublic final V get(String key) throws IOException
DataStorenull if not found.key - key or null for null resultIOExceptionpublic final DataStore<V> set(String key, V value) throws IOException
DataStorekey - keyvalue - value objectIOExceptionpublic DataStore<V> delete(String key) throws IOException
DataStorekey - key or null to ignoreIOExceptionpublic final DataStore<V> clear() throws IOException
DataStoreIOExceptionpublic boolean containsKey(String key) throws IOException
AbstractDataStoreDefault implementation is to call DataStore.get(String) and check if it is null.
containsKey in interface DataStore<V extends Serializable>containsKey in class AbstractDataStore<V extends Serializable>IOExceptionpublic boolean containsValue(V value) throws IOException
AbstractDataStoreDefault implementation is to call Collection.contains(Object) on DataStore.values().
containsValue in interface DataStore<V extends Serializable>containsValue in class AbstractDataStore<V extends Serializable>IOExceptionpublic boolean isEmpty()
throws IOException
AbstractDataStoreDefault implementation is to check if AbstractDataStore.size() is 0.
isEmpty in interface DataStore<V extends Serializable>isEmpty in class AbstractDataStore<V extends Serializable>IOExceptionpublic int size()
throws IOException
AbstractDataStoreDefault implementation is to call Set.size() on DataStore.keySet().
size in interface DataStore<V extends Serializable>size in class AbstractDataStore<V extends Serializable>IOExceptionpublic void save()
throws IOException
set(java.lang.String, V), delete(String), and
clear().IOExceptionCopyright © 2011–2025 Google. All rights reserved.