Class StorageProviderFactory

java.lang.Object
dev.crafty.core.storage.StorageProviderFactory

public class StorageProviderFactory extends Object
Factory for creating storage providers.
  • 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 type
      directory - The directory to store files in
      Returns:
      The storage provider
    • createYamlProvider

      public static <T> StorageProvider<String,T> createYamlProvider(Class<T> valueType, Path 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 type
      directory - 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 objects
      T - The type of object to store
      Parameters:
      keyType - The class of the key type
      valueType - The class of the value type
      directory - The directory to store files in
      Returns:
      The storage provider
    • createCachedProvider

      public static <K, T> StorageProvider<K,T> createCachedProvider(StorageProvider<K,T> provider)
      Creates a cached storage provider that wraps the given provider.
      Type Parameters:
      K - The type of key used to identify objects
      T - 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 type
      tableName - The name of the table to store objects in
      connectionUrl - The JDBC connection URL
      username - The database username
      password - 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 objects
      T - The type of object to store
      Parameters:
      keyType - The class of the key type
      valueType - The class of the value type
      tableName - The name of the table to store objects in
      connectionUrl - The JDBC connection URL
      username - The database username
      password - 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 type
      tableName - The name of the table to store objects in
      connectionUrl - The JDBC connection URL
      username - The database username
      password - 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 objects
      T - The type of object to store
      Parameters:
      keyType - The class of the key type
      valueType - The class of the value type
      tableName - The name of the table to store objects in
      connectionUrl - The JDBC connection URL
      username - The database username
      password - 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 type
      tableName - The name of the table to store objects in
      connectionUrl - 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 objects
      T - The type of object to store
      Parameters:
      keyType - The class of the key type
      valueType - The class of the value type
      tableName - The name of the table to store objects in
      connectionUrl - 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 create
      valueType - The class of the value type
      config - 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 objects
      T - The type of object to store
      Parameters:
      keyType - The class of the key type
      type - The type of storage provider to create
      valueType - The class of the value type
      config - The configuration for the storage provider
      Returns:
      The storage provider