Package dev.crafty.core.storage
Class AbstractStorageProvider<T,K>
java.lang.Object
dev.crafty.core.storage.AbstractStorageProvider<T,K>
- Type Parameters:
T
- The type of object to storeK
- The type of key used to identify objects
- All Implemented Interfaces:
StorageProvider<T,
K>
- Direct Known Subclasses:
MongoDbStorageProvider
,MySqlStorageProvider
,PostgresStorageProvider
,YamlStorageProvider
Abstract base implementation of StorageProvider that provides common functionality.
- Since:
- 1.0.0
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractStorageProvider
(Class<T> valueType) Creates a new AbstractStorageProvider. -
Method Summary
Modifier and TypeMethodDescriptionclose()
Closes the storage provider and releases any resources.Checks if an object exists in the storage.Initializes the storage provider.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface dev.crafty.core.storage.StorageProvider
delete, get, getAll, save
-
Field Details
-
valueType
-
-
Constructor Details
-
AbstractStorageProvider
Creates a new AbstractStorageProvider.- Parameters:
valueType
- The class of the value type
-
-
Method Details
-
exists
Checks if an object exists in the storage.- Specified by:
exists
in interfaceStorageProvider<T,
K> - Parameters:
key
- The key to check- Returns:
- A CompletableFuture that completes with true if the object exists, false otherwise
-
initialize
Initializes the storage provider. This method should be called before using the provider.- Specified by:
initialize
in interfaceStorageProvider<T,
K> - Returns:
- A CompletableFuture that completes when initialization is done
-
close
Closes the storage provider and releases any resources. This method should be called when the provider is no longer needed.- Specified by:
close
in interfaceStorageProvider<T,
K> - Returns:
- A CompletableFuture that completes when the provider is closed
-