Class FileSystemStorageService

java.lang.Object
com.adventure.services.FileSystemStorageService
All Implemented Interfaces:
StorageService

public class FileSystemStorageService extends Object
  • Field Details

    • config

      protected final Config config
      Application properties.
    • logger

      protected static final org.apache.logging.log4j.Logger logger
      Logger.
  • Constructor Details

    • FileSystemStorageService

      public FileSystemStorageService(Config config)
  • Method Details

    • listGames

      public List<String> listGames()
      Description copied from interface: StorageService
      Lists available games.
      Returns:
      A list of unique string identifiers of available games.
    • saveGame

      public void saveGame(Game game) throws GameStorageException
      Description copied from interface: StorageService
      Saves a game.
      Parameters:
      game - Game to save.
      Throws:
      GameStorageException - If an error occurs while saving the game.
    • loadGame

      public Game loadGame(String gameId) throws GameStorageException
      Description copied from interface: StorageService
      Loads a game.
      Parameters:
      gameId - Unique identifier of the game to load.
      Returns:
      An instance of the loaded game.
      Throws:
      GameStorageException - If an error occurs while loading the provided game.
    • deleteGame

      public void deleteGame(String gameId)
      Description copied from interface: StorageService
      Deletes a game.
      Parameters:
      gameId - Unique identifier of the game to delete.
    • newGame

      public Game newGame(String playerName)
      Description copied from interface: StorageService
      Creates a new game.
      Specified by:
      newGame in interface StorageService
      Parameters:
      playerName - The name of the player for the new game.
      Returns:
      An instance of the new game.