Package dev.crafty.core.storage
Class StorageProviderFactory
java.lang.Object
dev.crafty.core.storage.StorageProviderFactory
Factory for creating storage providers.
- Since:
- 1.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Configuration for storage providers.static enum
Enum representing the available storage types. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T,
K> StorageProvider <T, K> createCachedProvider
(StorageProvider<T, K> provider) Creates a cached storage provider that wraps the given provider.static <T> StorageProvider
<T, String> createMongoDbProvider
(Class<T> valueType, String tableName, String connectionUrl) Creates a MongoDb storage provider.static <T> StorageProvider
<T, String> createMySqlProvider
(Class<T> valueType, String tableName, String connectionUrl, String username, String password) Creates a MySQL storage provider.static <T> StorageProvider
<T, String> createPostgresProvider
(Class<T> valueType, String tableName, String connectionUrl, String username, String password) Creates a PostgreSQL storage provider.static <T> StorageProvider
<T, String> createProvider
(StorageProviderFactory.StorageType type, Class<T> valueType, StorageProviderFactory.StorageConfig config) Creates a storage provider based on the specified type.static <T> StorageProvider
<T, String> createYamlProvider
(Class<T> valueType, String directory) Creates a YAML storage provider.static <T> StorageProvider
<T, String> createYamlProvider
(Class<T> valueType, Path directory) Creates a YAML storage provider.
-
Constructor Details
-
StorageProviderFactory
public StorageProviderFactory()
-
-
Method Details
-
createYamlProvider
public static <T> StorageProvider<T,String> createYamlProvider(Class<T> valueType, String directory) Creates a YAML storage provider.- Type Parameters:
T
- The type of object to store- Parameters:
valueType
- The class of the value typedirectory
- The directory to store files in- Returns:
- The storage provider
-
createYamlProvider
Creates a YAML storage provider.- Type Parameters:
T
- The type of object to store- Parameters:
valueType
- The class of the value typedirectory
- The directory to store files in- Returns:
- The storage provider
-
createCachedProvider
Creates a cached storage provider that wraps the given provider.- Type Parameters:
T
- The type of object to storeK
- The type of key used to identify objects- Parameters:
provider
- The provider to wrap- Returns:
- The cached storage provider
-
createPostgresProvider
public static <T> StorageProvider<T,String> createPostgresProvider(Class<T> valueType, String tableName, String connectionUrl, String username, String password) Creates a PostgreSQL storage provider.- Type Parameters:
T
- The type of object to store- Parameters:
valueType
- The class of the value typetableName
- The name of the table to store objects inconnectionUrl
- The JDBC connection URLusername
- The database usernamepassword
- The database password- Returns:
- The storage provider
-
createMySqlProvider
public static <T> StorageProvider<T,String> createMySqlProvider(Class<T> valueType, String tableName, String connectionUrl, String username, String password) Creates a MySQL storage provider.- Type Parameters:
T
- The type of object to store- Parameters:
valueType
- The class of the value typetableName
- The name of the table to store objects inconnectionUrl
- The JDBC connection URLusername
- The database usernamepassword
- The database password- Returns:
- The storage provider
-
createMongoDbProvider
public static <T> StorageProvider<T,String> createMongoDbProvider(Class<T> valueType, String tableName, String connectionUrl) Creates a MongoDb storage provider.- Type Parameters:
T
- The type of object to store- Parameters:
valueType
- The class of the value typetableName
- The name of the table to store objects inconnectionUrl
- The JDBC connection URL- Returns:
- The storage provider
-
createProvider
public static <T> StorageProvider<T,String> createProvider(StorageProviderFactory.StorageType type, Class<T> valueType, StorageProviderFactory.StorageConfig config) Creates a storage provider based on the specified type.- Type Parameters:
T
- The type of object to store- Parameters:
type
- The type of storage provider to createvalueType
- The class of the value typeconfig
- The configuration for the storage provider- Returns:
- The storage provider
-