Class GameMetadata

java.lang.Object
net.royalur.model.GameMetadata

public class GameMetadata extends Object
Stores the metadata of games, such as the date the game was played, the players of the game, and the game rules.
  • Field Details

    • START_DATETIME_KEY

      public static final String START_DATETIME_KEY
      The key for storing when a game started.
      See Also:
    • END_DATETIME_KEY

      public static final String END_DATETIME_KEY
      The key for storing when a game was finished.
      See Also:
    • TIME_CONTROL_KEY

      public static final String TIME_CONTROL_KEY
      The key for storing the time control of a game.
      See Also:
    • STANDARD_KEYS

      public static final Set<String> STANDARD_KEYS
      Standard metadata keys that are commonly used.
  • Constructor Details

    • GameMetadata

      public GameMetadata(Map<String,String> metadata)
      Instantiates metadata for a game of the Royal Game of Ur.
      Parameters:
      metadata - The metadata of the game.
    • GameMetadata

      public GameMetadata()
      Instantiates an empty metadata for a game.
  • Method Details

    • startingNow

      public static GameMetadata startingNow()
    • copy

      public GameMetadata copy()
      Creates a copy of this metadata.
      Returns:
      A copy of this metadata.
    • getAll

      public Map<String,String> getAll()
      Retrieves a copy of all the metadata stored.
      Returns:
      A copy of all the metadata stored.
    • has

      public boolean has(String key)
      Checks whether there is any metadata associated with key.
      Parameters:
      key - The metadata key to check.
      Returns:
      Whether there is any metadata associated with key.
    • get

      @Nullable public String get(String key)
      Get the metadata value associated with key, or null if there is no value associated with the key.
      Parameters:
      key - The metadata key to retrieve.
      Returns:
      The metadata value associated with key, or else null.
    • remove

      public void remove(String key)
      Removes any metadata value associated with key.
      Parameters:
      key - The metadata key to remove.
    • clear

      public void clear()
      Removes all metadata.
    • put

      public void put(String key, String value)
      Add a new metadata value, value, associated with key.
      Parameters:
      key - The metadata key to set the value for.
      value - The value to associate with the given key.
    • hasStartTime

      public boolean hasStartTime()
      Checks whether this metadata contains the date and time when this game began.
      Returns:
      Whether this metadata contains the date and time when this game began.
    • getStartTime

      @Nullable public ZonedDateTime getStartTime()
      Gets the date and time when this game began, or null if no end time is included in this game's metadata.
      Returns:
      The date and time when this game began, or else null.
    • setStartTime

      public void setStartTime(TemporalAccessor datetime)
      Sets the date and time when this game began.
      Parameters:
      datetime - The date and time when this game began.
    • hasEndTime

      public boolean hasEndTime()
      Checks whether this metadata contains the date and time when this game was finished.
      Returns:
      Whether this metadata contains the date and time when this game was finished.
    • getEndTime

      @Nullable public ZonedDateTime getEndTime()
      Gets the date and time when this game was finished, or null if no end time is included in this game's metadata.
      Returns:
      The date and time when this game was finished, or else null.
    • setEndTime

      public void setEndTime(TemporalAccessor datetime)
      Sets the date and time when this game was finished.
      Parameters:
      datetime - The date and time when this game was finished.
    • hasTimeControl

      public boolean hasTimeControl()
      Checks whether this metadata contains the time control used for the game.
      Returns:
      Whether this metadata contains the time control used for the game.
    • getTimeControl

      @Nullable public TimeControl getTimeControl()
      Gets the time control used for this game, or null if no time control was included in this game's metadata.
      Returns:
      The time control used for this game, or else null.
    • setTimeControl

      public void setTimeControl(TimeControl timeControl)
      Sets the time control used for this game.
      Parameters:
      timeControl - The time control used for this game.
    • equals

      public boolean equals(@Nullable Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • parseDatetime

      public static ZonedDateTime parseDatetime(String datetime)
    • formatDatetime

      public static String formatDatetime(TemporalAccessor datetime)