Class AbstractMemoryDataStore<V> (1.43.2)

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

Name Description
V

Constructors

AbstractMemoryDataStore(DataStoreFactory dataStoreFactory, String id)

protected AbstractMemoryDataStore(DataStoreFactory dataStoreFactory, String id)
Parameters
Name Description
dataStoreFactory DataStoreFactory

data store factory

id String

data store ID

Fields

keyValueMap

protected HashMap<String,byte[]> keyValueMap

Data store map from the key to the value.

Field Value
Type Description
HashMap<String,byte[]>

Methods

clear()

public final DataStore<V> clear()
Returns
Type Description
DataStore<V>
Exceptions
Type Description
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
Name Description
key String
Returns
Type Description
boolean
Overrides
Exceptions
Type Description
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
Name Description
value V
Returns
Type Description
boolean
Overrides
Exceptions
Type Description
IOException

delete(String key)

public DataStore<V> delete(String key)
Parameter
Name Description
key String
Returns
Type Description
DataStore<V>
Exceptions
Type Description
IOException

get(String key)

public final V get(String key)
Parameter
Name Description
key String
Returns
Type Description
V
Exceptions
Type Description
IOException

isEmpty()

public boolean isEmpty()

Returns whether there are any stored keys.

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

Returns
Type Description
boolean
Overrides
Exceptions
Type Description
IOException

keySet()

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

save()

public void save()

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

Exceptions
Type Description
IOException

set(String key, V value)

public final DataStore<V> set(String key, V value)
Parameters
Name Description
key String
value V
Returns
Type Description
DataStore<V>
Exceptions
Type Description
IOException

size()

public int size()

Returns the number of stored keys.

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

Returns
Type Description
int
Overrides
Exceptions
Type Description
IOException

toString()

public String toString()
Returns
Type Description
String
Overrides

values()

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