Package org.progettoedids.repositories
Class LabyrinthRepository
java.lang.Object
org.progettoedids.repositories.LabyrinthRepository
This class holds a map composed of Labyrinth names and associated Labyrinth.Builder(s).
Labyrinth(s) can be added, retrieved built or removed by calling the respective methods. It's not possible to add a Labyrinth whose name is already present in the repository, in order to so it's necessary to remove it first.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLabyrinth(Labyrinth.Builder labyrinth) Adds a Labyrinth.Builder to the repository.static LabyrinthRepositorygetLabyrinth(String labyrinthName) Returns a newly built instance of a Labyrinth with the specified name and a random seed.getLabyrinth(String labyrinthName, long randomGeneratorSeed) Returns a newly built instance of a Labyrinth with the specified name and seed.String[]getNames()Returns all the names of the Labyrinth(s) held in this repository.String[]getNames(Difficulty difficulty) Returns the names of all the Labyrinth(s) with the specified Difficulty.voidloadLabyrinths(LabyrinthLoader labyrinthLoader) Loads all the Labyrinth.Builder supplied by a specialized loader.voidremoveLabyrinth(String labyrinthName) Removes a Labyrinth.Builder with the given name from the Labyrinth.
-
Field Details
-
labyRepo
-
-
Constructor Details
-
LabyrinthRepository
protected LabyrinthRepository()
-
-
Method Details
-
getInstance
-
getNames
Returns all the names of the Labyrinth(s) held in this repository.- Returns:
- an array of String(s) with the names of the Labyrinth(s)
-
getNames
Returns the names of all the Labyrinth(s) with the specified Difficulty.- Parameters:
difficulty- The Difficulty to filter. Must not be null- Returns:
- an array of String(s) with the name of the Labyrinth(s)
-
getLabyrinth
Returns a newly built instance of a Labyrinth with the specified name and a random seed.- Parameters:
labyrinthName- The name of the Labyrinth to retrieve. Must not be null- Returns:
- a Labyrinth instance
- Throws:
NoSuchElementException- when the name supplied doesn't match any stored Labyrinth
-
getLabyrinth
Returns a newly built instance of a Labyrinth with the specified name and seed.- Parameters:
labyrinthName- The name of the Labyrinth to retrieve. Must not be nullrandomGeneratorSeed- A long value representing the seed to use to initialize the random generator of the Labyrinth- Returns:
- a Labyrinth instance
-
addLabyrinth
Adds a Labyrinth.Builder to the repository.- Parameters:
labyrinth- a Labyrinth.Builder properly configured. Must not be null- Throws:
IllegalArgumentException- if a Labyrinth with same name was already in the repository
-
loadLabyrinths
Loads all the Labyrinth.Builder supplied by a specialized loader.- Parameters:
labyrinthLoader- an instance of a specialized LabyrinthLoader. Must not be null
-
removeLabyrinth
Removes a Labyrinth.Builder with the given name from the Labyrinth.- Parameters:
labyrinthName- a String representing the name of a Labyrinth- Throws:
IllegalArgumentException- if a Labyrinth with the same name couldn't be found in the repository
-