Class AbstractMemoryDataStore<V extends Serializable>
java.lang.Object
com.google.api.client.util.store.AbstractDataStore<V>
com.google.api.client.util.store.AbstractMemoryDataStore<V>
- Type Parameters:
V- serializable type of the mapped value
- All Implemented Interfaces:
DataStore<V>
- Direct Known Subclasses:
FileDataStoreFactory.FileDataStore, MemoryDataStoreFactory.MemoryDataStore
Abstract, thread-safe, in-memory implementation of a data store factory.
-
Field Summary
FieldsModifier and TypeFieldDescriptionData store map from the key to the value.private final LockLock on access to the store. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractMemoryDataStore(DataStoreFactory dataStoreFactory, String id) -
Method Summary
Modifier and TypeMethodDescriptionclear()Deletes all of the stored keys and values.booleancontainsKey(String key) Returns whether the store contains the given key.booleancontainsValue(V value) Returns whether the store contains the given value.Deletes the stored key and value based on the given key, or ignored if the key doesn't already exist.final VReturns the stored value for the given key ornullif not found.booleanisEmpty()Returns whether there are any stored keys.keySet()Returns the unmodifiable set of all stored keys.voidsave()Stores the given value for the given key (replacing any existing value).intsize()Returns the number of stored keys.toString()final Collection<V> values()Returns the unmodifiable collection of all stored values.Methods inherited from class AbstractDataStore
getDataStoreFactory, getId
-
Field Details
-
lock
Lock on access to the store. -
keyValueMap
-
-
Constructor Details
-
AbstractMemoryDataStore
- Parameters:
dataStoreFactory- data store factoryid- data store ID
-
-
Method Details
-
keySet
Description copied from interface:DataStoreReturns the unmodifiable set of all stored keys.Order of the keys is not specified.
- Throws:
IOException
-
values
Description copied from interface:DataStoreReturns the unmodifiable collection of all stored values.- Throws:
IOException
-
get
Description copied from interface:DataStoreReturns the stored value for the given key ornullif not found.- Parameters:
key- key ornullfornullresult- Throws:
IOException
-
set
Description copied from interface:DataStoreStores the given value for the given key (replacing any existing value).- Parameters:
key- keyvalue- value object- Throws:
IOException
-
delete
Description copied from interface:DataStoreDeletes the stored key and value based on the given key, or ignored if the key doesn't already exist.- Parameters:
key- key ornullto ignore- Throws:
IOException
-
clear
Description copied from interface:DataStoreDeletes all of the stored keys and values.- Throws:
IOException
-
containsKey
Description copied from class:AbstractDataStoreReturns whether the store contains the given key.Default implementation is to call
DataStore.get(String)and check if it isnull.- Specified by:
containsKeyin interfaceDataStore<V extends Serializable>- Overrides:
containsKeyin classAbstractDataStore<V extends Serializable>- Throws:
IOException
-
containsValue
Description copied from class:AbstractDataStoreReturns whether the store contains the given value.Default implementation is to call
Collection.contains(Object)onDataStore.values().- Specified by:
containsValuein interfaceDataStore<V extends Serializable>- Overrides:
containsValuein classAbstractDataStore<V extends Serializable>- Throws:
IOException
-
isEmpty
Description copied from class:AbstractDataStoreReturns whether there are any stored keys.Default implementation is to check if
AbstractDataStore.size()is0.- Specified by:
isEmptyin interfaceDataStore<V extends Serializable>- Overrides:
isEmptyin classAbstractDataStore<V extends Serializable>- Throws:
IOException
-
size
Description copied from class:AbstractDataStoreReturns the number of stored keys.Default implementation is to call
Set.size()onDataStore.keySet().- Specified by:
sizein interfaceDataStore<V extends Serializable>- Overrides:
sizein classAbstractDataStore<V extends Serializable>- Throws:
IOException
-
save
- Throws:
IOException
-
toString
-