Class GsonDAO

java.lang.Object
net.pottercraft.ollivanders2.GsonDAO
All Implemented Interfaces:
GenericDAO

public class GsonDAO extends Object implements GenericDAO
GSON data persistance layer
  • Field Details

  • Constructor Details

    • GsonDAO

      public GsonDAO()
      Constructor
  • Method Details

    • writeHouses

      public void writeHouses(@NotNull @NotNull Map<UUID,O2HouseType> map)
      Write the house sort data
      Specified by:
      writeHouses in interface GenericDAO
      Parameters:
      map - a map of player and house data as strings
    • writeHousePoints

      public void writeHousePoints(@NotNull @NotNull Map<O2HouseType,Integer> map)
      Write house points
      Specified by:
      writeHousePoints in interface GenericDAO
      Parameters:
      map - a map of the house points data as strings
    • writeApparateData

      public void writeApparateData(@NotNull @NotNull HashMap<String,org.bukkit.Location> locations)
      Save the apparate locations
      Parameters:
      locations - the map of location names to Locations
    • writeSaveData

      public void writeSaveData(@NotNull @NotNull HashMap<String,String> map, @NotNull @NotNull String filename)
      Write save data serialized in to a hashmap of String, String pairs
      Specified by:
      writeSaveData in interface GenericDAO
      Parameters:
      map - the map of saved data
      filename - the file to write to
    • writeSaveData

      public void writeSaveData(@NotNull @NotNull Map<String,Map<String,String>> map, @NotNull @NotNull String filename)
      Write save data serialized in to a map of String, Map pairs
      Specified by:
      writeSaveData in interface GenericDAO
      Parameters:
      map - a map of the player data as strings
      filename - the name of the output stream
    • writeSaveData

      public void writeSaveData(@NotNull @NotNull List<Map<String,String>> map, @NotNull @NotNull String filename)
      Write the prophecies to json file
      Specified by:
      writeSaveData in interface GenericDAO
      Parameters:
      map - a map of prophecy data as strings
      filename - the name of the output stream
    • readHouses

      @Nullable public @Nullable Map<UUID,O2HouseType> readHouses()
      Read the house sort data from json
      Specified by:
      readHouses in interface GenericDAO
      Returns:
      a map of player UUIDs and their house
    • readHousePoints

      @Nullable public @Nullable Map<O2HouseType,Integer> readHousePoints()
      read the house points json data
      Specified by:
      readHousePoints in interface GenericDAO
      Returns:
      a map of houses and their points
    • readApparateLocation

      @Nullable public @Nullable HashMap<String,org.bukkit.Location> readApparateLocation()
      Read the apparate locations
      Returns:
      a map of apparate locations or null if load failed
    • readSavedDataMapStringMap

      @Nullable public @Nullable Map<String,Map<String,String>> readSavedDataMapStringMap(@NotNull @NotNull String filename)
      Read a serilaized map of strings and maps from json file
      Specified by:
      readSavedDataMapStringMap in interface GenericDAO
      Parameters:
      filename - the input stream to read
      Returns:
      a map of the player json data
    • readSavedDataListMap

      @Nullable public @Nullable List<Map<String,String>> readSavedDataListMap(@NotNull @NotNull String filename)
      Read a serilized list of maps from json file
      Specified by:
      readSavedDataListMap in interface GenericDAO
      Parameters:
      filename - the input stream to read
      Returns:
      a list of the serialized stationary spells