Class FileSaveStorage

java.lang.Object
technology.sola.engine.storage.FileSaveStorage
All Implemented Interfaces:
SaveStorage

public class FileSaveStorage extends Object implements SaveStorage
A SaveStorage implementation that stores saves on the file system.
  • Constructor Details

    • FileSaveStorage

      public FileSaveStorage()
  • Method Details

    • changeSaveDirectory

      public void changeSaveDirectory(String path)
      Description copied from interface: SaveStorage
      Changes the directory in which saves are stored.
      Specified by:
      changeSaveDirectory in interface SaveStorage
      Parameters:
      path - the path to where saves should be stored
    • load

      public void load(String path, Consumer<String> onSuccess, Consumer<Exception> onFailure)
      Description copied from interface: SaveStorage
      Loads a save. The loaded save will be passed to the onSuccess callback.
      Specified by:
      load in interface SaveStorage
      Parameters:
      path - the path to the save
      onSuccess - callback that is called when the save is loaded successfully
      onFailure - callback that is called when the save fails to load
    • save

      public void save(String path, String content, Runnable onSuccess, Consumer<Exception> onFailure)
      Description copied from interface: SaveStorage
      Persists a save.
      Specified by:
      save in interface SaveStorage
      Parameters:
      path - the path to the save
      content - the content of the save to be persisted
      onSuccess - callback that is called when the save is persisted successfully
      onFailure - callback that is called when the save fails to persist
    • delete

      public void delete(String path, Runnable onSuccess, Consumer<Exception> onFailure)
      Description copied from interface: SaveStorage
      Deletes a save.
      Specified by:
      delete in interface SaveStorage
      Parameters:
      path - the path to the save
      onSuccess - the callback that is called when the save is deleted successfully
      onFailure - the callback that is called when the save fails to delete
    • exists

      public boolean exists(String path)
      Description copied from interface: SaveStorage
      Checks if a save exists.
      Specified by:
      exists in interface SaveStorage
      Parameters:
      path - the path to the save
      Returns:
      true if the save exists