Class AbstractMemoryDataStore<V> (1.42.3)

public class AbstractMemoryDataStore<V> extends AbstractDataStore<V>

Abstract, thread-safe, in-memory implementation of a data store factory.

Inheritance

java.lang.Object > AbstractDataStore > AbstractMemoryDataStore<V>

Type Parameter

NameDescription
V

Constructors

AbstractMemoryDataStore(DataStoreFactory dataStoreFactory, String id)

protected AbstractMemoryDataStore(DataStoreFactory dataStoreFactory, String id)
Parameters
NameDescription
dataStoreFactoryDataStoreFactory

data store factory

idString

data store ID

Fields

keyValueMap

protected HashMap<String,byte[]> keyValueMap

Data store map from the key to the value.

Field Value
TypeDescription
HashMap<String,byte[]>

Methods

clear()

public final DataStore<V> clear()
Returns
TypeDescription
DataStore<V>
Exceptions
TypeDescription
IOException

containsKey(String key)

public boolean containsKey(String key)

Returns whether the store contains the given key.

Default implementation is to call #get(String) and check if it is null.

Parameter
NameDescription
keyString
Returns
TypeDescription
boolean
Overrides Exceptions
TypeDescription
IOException

containsValue(V value)

public boolean containsValue(V value)

Returns whether the store contains the given value.

Default implementation is to call Collection#contains(Object) on #values().

Parameter
NameDescription
valueV
Returns
TypeDescription
boolean
Overrides Exceptions
TypeDescription
IOException

delete(String key)

public DataStore<V> delete(String key)
Parameter
NameDescription
keyString
Returns
TypeDescription
DataStore<V>
Exceptions
TypeDescription
IOException

get(String key)

public final V get(String key)
Parameter
NameDescription
keyString
Returns
TypeDescription
V
Exceptions
TypeDescription
IOException

isEmpty()

public boolean isEmpty()

Returns whether there are any stored keys.

Default implementation is to check if #size() is 0.

Returns
TypeDescription
boolean
Overrides Exceptions
TypeDescription
IOException

keySet()

public final Set<String> keySet()
Returns
TypeDescription
Set<String>
Exceptions
TypeDescription
IOException

save()

public void save()

Persist the key-value map into storage at the end of #set, #delete(String), and #clear().

Exceptions
TypeDescription
IOException

set(String key, V value)

public final DataStore<V> set(String key, V value)
Parameters
NameDescription
keyString
valueV
Returns
TypeDescription
DataStore<V>
Exceptions
TypeDescription
IOException

size()

public int size()

Returns the number of stored keys.

Default implementation is to call Set#size() on #keySet().

Returns
TypeDescription
int
Overrides Exceptions
TypeDescription
IOException

toString()

public String toString()
Returns
TypeDescription
String
Overrides

values()

public final Collection<V> values()
Returns
TypeDescription
Collection<V>
Exceptions
TypeDescription
IOException