Package com.google.api.client.util.store
Class AbstractDataStoreFactory
java.lang.Object
com.google.api.client.util.store.AbstractDataStoreFactory
- All Implemented Interfaces:
DataStoreFactory
- Direct Known Subclasses:
FileDataStoreFactory
,JdoDataStoreFactory
,MemoryDataStoreFactory
Abstract data store factory implementation.
- Since:
- 1.16
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map
<String, DataStore<? extends Serializable>> Map of data store ID to data store.private static final Pattern
Pattern to control possible values for theid
parameter ofgetDataStore(String)
.private final Lock
Lock on access to the data store map. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract <V extends Serializable>
DataStore<V> Returns a new instance of a type-specific data store based on the given unique ID.final <V extends Serializable>
DataStore<V> getDataStore
(String id) Returns a type-specific data store based on the given unique ID.
-
Field Details
-
lock
Lock on access to the data store map. -
dataStoreMap
Map of data store ID to data store. -
ID_PATTERN
Pattern to control possible values for theid
parameter ofgetDataStore(String)
.
-
-
Constructor Details
-
AbstractDataStoreFactory
public AbstractDataStoreFactory()
-
-
Method Details
-
getDataStore
Description copied from interface:DataStoreFactory
Returns a type-specific data store based on the given unique ID.If a data store by that ID does not already exist, it should be created now, stored for later access, and returned. Otherwise, if there is already a data store by that ID, it should be returned. The
DataStore.getId()
must match theid
parameter from this method.The ID must be at least 1 and at most 30 characters long, and must contain only alphanumeric or underscore characters.
- Specified by:
getDataStore
in interfaceDataStoreFactory
- Type Parameters:
V
- serializable type of the mapped value- Parameters:
id
- unique ID to refer to typed data store- Throws:
IOException
-
createDataStore
protected abstract <V extends Serializable> DataStore<V> createDataStore(String id) throws IOException Returns a new instance of a type-specific data store based on the given unique ID.The
DataStore.getId()
must match theid
parameter from this method.- Type Parameters:
V
- serializable type of the mapped value- Parameters:
id
- unique ID to refer to typed data store- Throws:
IOException
-