Package dev.crafty.core.storage
Class StorageProviderFactory
java.lang.Object
dev.crafty.core.storage.StorageProviderFactory
Factory for creating storage providers.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classConfiguration for storage providers.static enumEnum representing the available storage types. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <K,T> StorageProvider <K, T> createCachedProvider(StorageProvider<K, T> provider) Creates a cached storage provider that wraps the given provider.static <K,T> StorageProvider <K, T> createMongoDbProvider(Class<K> keyType, Class<T> valueType, String tableName, String connectionUrl) Creates a MongoDb storage provider with generic key type.static <T> StorageProvider<String, T> createMongoDbProvider(Class<T> valueType, String tableName, String connectionUrl) Creates a MongoDb storage provider with String keys.static <K,T> StorageProvider <K, T> createMySqlProvider(Class<K> keyType, Class<T> valueType, String tableName, String connectionUrl, String username, String password) Creates a MySQL storage provider with generic key type.static <T> StorageProvider<String, T> createMySqlProvider(Class<T> valueType, String tableName, String connectionUrl, String username, String password) Creates a MySQL storage provider with String keys.static <K,T> StorageProvider <K, T> createPostgresProvider(Class<K> keyType, Class<T> valueType, String tableName, String connectionUrl, String username, String password) Creates a PostgreSQL storage provider with generic key type.static <T> StorageProvider<String, T> createPostgresProvider(Class<T> valueType, String tableName, String connectionUrl, String username, String password) Creates a PostgreSQL storage provider with String keys.static <T> StorageProvider<String, T> createProvider(StorageProviderFactory.StorageType type, Class<T> valueType, StorageProviderFactory.StorageConfig config) Creates a storage provider based on the specified type with String keys.static <K,T> StorageProvider <K, T> createProvider(Class<K> keyType, StorageProviderFactory.StorageType type, Class<T> valueType, StorageProviderFactory.StorageConfig config) Creates a storage provider based on the specified type with generic key type.static <K,T> StorageProvider <K, T> createYamlProvider(Class<K> keyType, Class<T> valueType, Path directory) Creates a YAML storage provider with generic key type.static <T> StorageProvider<String, T> createYamlProvider(Class<T> valueType, String directory) Creates a YAML storage provider with String keys.static <T> StorageProvider<String, T> createYamlProvider(Class<T> valueType, Path directory) Creates a YAML storage provider with String keys.
-
Constructor Details
-
StorageProviderFactory
public StorageProviderFactory()
-
-
Method Details
-
createYamlProvider
public static <T> StorageProvider<String,T> createYamlProvider(Class<T> valueType, String directory) Creates a YAML storage provider with String keys.- 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 with String keys.- 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
public static <K,T> StorageProvider<K,T> createYamlProvider(Class<K> keyType, Class<T> valueType, Path directory) Creates a YAML storage provider with generic key type.- Type Parameters:
K- The type of key used to identify objectsT- The type of object to store- Parameters:
keyType- The class of the key typevalueType- 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:
K- The type of key used to identify objectsT- The type of object to store- Parameters:
provider- The provider to wrap- Returns:
- The cached storage provider
-
createPostgresProvider
public static <T> StorageProvider<String,T> createPostgresProvider(Class<T> valueType, String tableName, String connectionUrl, String username, String password) Creates a PostgreSQL storage provider with String keys.- 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
-
createPostgresProvider
public static <K,T> StorageProvider<K,T> createPostgresProvider(Class<K> keyType, Class<T> valueType, String tableName, String connectionUrl, String username, String password) Creates a PostgreSQL storage provider with generic key type.- Type Parameters:
K- The type of key used to identify objectsT- The type of object to store- Parameters:
keyType- The class of the key typevalueType- 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<String,T> createMySqlProvider(Class<T> valueType, String tableName, String connectionUrl, String username, String password) Creates a MySQL storage provider with String keys.- 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 <K,T> StorageProvider<K,T> createMySqlProvider(Class<K> keyType, Class<T> valueType, String tableName, String connectionUrl, String username, String password) Creates a MySQL storage provider with generic key type.- Type Parameters:
K- The type of key used to identify objectsT- The type of object to store- Parameters:
keyType- The class of the key typevalueType- 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<String,T> createMongoDbProvider(Class<T> valueType, String tableName, String connectionUrl) Creates a MongoDb storage provider with String keys.- 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
-
createMongoDbProvider
public static <K,T> StorageProvider<K,T> createMongoDbProvider(Class<K> keyType, Class<T> valueType, String tableName, String connectionUrl) Creates a MongoDb storage provider with generic key type.- Type Parameters:
K- The type of key used to identify objectsT- The type of object to store- Parameters:
keyType- The class of the key typevalueType- 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<String,T> createProvider(StorageProviderFactory.StorageType type, Class<T> valueType, StorageProviderFactory.StorageConfig config) Creates a storage provider based on the specified type with String keys.- 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
-
createProvider
public static <K,T> StorageProvider<K,T> createProvider(Class<K> keyType, StorageProviderFactory.StorageType type, Class<T> valueType, StorageProviderFactory.StorageConfig config) Creates a storage provider based on the specified type with generic key type.- Type Parameters:
K- The type of key used to identify objectsT- The type of object to store- Parameters:
keyType- The class of the key typetype- The type of storage provider to createvalueType- The class of the value typeconfig- The configuration for the storage provider- Returns:
- The storage provider
-