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, getId
protected AbstractMemoryDataStore(DataStoreFactory dataStoreFactory, String id)
dataStoreFactory
- data store factoryid
- data store IDpublic final Set<String> keySet() throws IOException
DataStore
Order of the keys is not specified.
IOException
public final Collection<V> values() throws IOException
DataStore
IOException
public final V get(String key) throws IOException
DataStore
null
if not found.key
- key or null
for null
resultIOException
public final DataStore<V> set(String key, V value) throws IOException
DataStore
key
- keyvalue
- value objectIOException
public DataStore<V> delete(String key) throws IOException
DataStore
key
- key or null
to ignoreIOException
public final DataStore<V> clear() throws IOException
DataStore
IOException
public boolean containsKey(String key) throws IOException
AbstractDataStore
Default 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>
IOException
public boolean containsValue(V value) throws IOException
AbstractDataStore
Default implementation is to call Collection.contains(Object)
on DataStore.values()
.
containsValue
in interface DataStore<V extends Serializable>
containsValue
in class AbstractDataStore<V extends Serializable>
IOException
public boolean isEmpty() throws IOException
AbstractDataStore
Default implementation is to check if AbstractDataStore.size()
is 0
.
isEmpty
in interface DataStore<V extends Serializable>
isEmpty
in class AbstractDataStore<V extends Serializable>
IOException
public int size() throws IOException
AbstractDataStore
Default implementation is to call Set.size()
on DataStore.keySet()
.
size
in interface DataStore<V extends Serializable>
size
in class AbstractDataStore<V extends Serializable>
IOException
public void save() throws IOException
set(java.lang.String, V)
, delete(String)
, and
clear()
.IOException
Copyright © 2011–2019 Google. All rights reserved.