Interface DataStore<V>

public interface DataStore<V>

Stores and manages serializable data of a specific type, where the key is a string and the value is a Serializable object.

null keys or values are not allowed. Implementation should be thread-safe.

Type Parameter

NameDescription
V

Methods

clear()

public abstract DataStore<V> clear()

Deletes all of the stored keys and values.

Returns
TypeDescription
DataStore<V>
Exceptions
TypeDescription
IOException

containsKey(String key)

public abstract boolean containsKey(String key)

Returns whether the store contains the given key.

Parameter
NameDescription
keyString
Returns
TypeDescription
boolean
Exceptions
TypeDescription
IOException

containsValue(V value)

public abstract boolean containsValue(V value)

Returns whether the store contains the given value.

Parameter
NameDescription
valueV
Returns
TypeDescription
boolean
Exceptions
TypeDescription
IOException

delete(String key)

public abstract 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.

Parameter
NameDescription
keyString

key or null to ignore

Returns
TypeDescription
DataStore<V>
Exceptions
TypeDescription
IOException

get(String key)

public abstract V get(String key)

Returns the stored value for the given key or null if not found.

Parameter
NameDescription
keyString

key or null for null result

Returns
TypeDescription
V
Exceptions
TypeDescription
IOException

getDataStoreFactory()

public abstract DataStoreFactory getDataStoreFactory()

Returns the data store factory.

Returns
TypeDescription
DataStoreFactory

getId()

public abstract String getId()

Returns the data store ID.

Returns
TypeDescription
String

isEmpty()

public abstract boolean isEmpty()

Returns whether there are any stored keys.

Returns
TypeDescription
boolean
Exceptions
TypeDescription
IOException

keySet()

public abstract Set<String> keySet()

Returns the unmodifiable set of all stored keys.

Order of the keys is not specified.

Returns
TypeDescription
Set<String>
Exceptions
TypeDescription
IOException

set(String key, V value)

public abstract DataStore<V> set(String key, V value)

Stores the given value for the given key (replacing any existing value).

Parameters
NameDescription
keyString

key

valueV

value object

Returns
TypeDescription
DataStore<V>
Exceptions
TypeDescription
IOException

size()

public abstract int size()

Returns the number of stored keys.

Returns
TypeDescription
int
Exceptions
TypeDescription
IOException

values()

public abstract Collection<V> values()

Returns the unmodifiable collection of all stored values.

Returns
TypeDescription
Collection<V>
Exceptions
TypeDescription
IOException