Class YamlStorageProvider<K,V>

java.lang.Object
dev.crafty.core.storage.AbstractStorageProvider<K,V>
dev.crafty.core.storage.providers.YamlStorageProvider<K,V>
All Implemented Interfaces:
StorageProvider<K,V>

public class YamlStorageProvider<K,V> extends AbstractStorageProvider<K,V>
  • Constructor Details

    • YamlStorageProvider

      public YamlStorageProvider(Class<V> valueType, Path directory)
    • YamlStorageProvider

      public YamlStorageProvider(Class<V> valueType, Path directory, String fileExtension)
  • Method Details

    • initialize

      public CompletableFuture<Void> initialize()
      Description copied from interface: StorageProvider
      Initializes the storage provider. This method should be called before using the provider.
      Specified by:
      initialize in interface StorageProvider<K,V>
      Overrides:
      initialize in class AbstractStorageProvider<K,V>
      Returns:
      A CompletableFuture that completes when initialization is done
    • save

      public CompletableFuture<Void> save(K key, V value)
      Description copied from interface: StorageProvider
      Saves an object to the storage.
      Parameters:
      key - The key to identify the object
      value - The object to save
      Returns:
      A CompletableFuture that completes when the operation is done
    • get

      public CompletableFuture<Optional<V>> get(K key)
      Description copied from interface: StorageProvider
      Retrieves an object from the storage.
      Parameters:
      key - The key of the object to retrieve
      Returns:
      A CompletableFuture that completes with the retrieved object, or empty if not found
    • getAll

      public CompletableFuture<Collection<V>> getAll()
      Description copied from interface: StorageProvider
      Retrieves all objects from the storage.
      Returns:
      A CompletableFuture that completes with a collection of all objects
    • delete

      public CompletableFuture<Void> delete(K key)
      Description copied from interface: StorageProvider
      Deletes an object from the storage.
      Parameters:
      key - The key of the object to delete
      Returns:
      A CompletableFuture that completes when the operation is done