Package net.royalur.model
Class GameMetadata
java.lang.Object
net.royalur.model.GameMetadata
Stores the metadata of games, such as the date the game was played,
the players of the game, and the game rules.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionInstantiates an empty metadata for a game.GameMetadata
(Map<String, String> metadata) Instantiates metadata for a game of the Royal Game of Ur. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Removes all metadata.copy()
Creates a copy of this metadata.boolean
static String
formatDatetime
(TemporalAccessor datetime) Get the metadata value associated withkey
, ornull
if there is no value associated with the key.getAll()
Retrieves a copy of all the metadata stored.Gets the date and time when this game was finished, ornull
if no end time is included in this game's metadata.Gets the date and time when this game began, ornull
if no end time is included in this game's metadata.Gets the time control used for this game, ornull
if no time control was included in this game's metadata.boolean
Checks whether there is any metadata associated withkey
.boolean
Checks whether this metadata contains the date and time when this game was finished.boolean
Checks whether this metadata contains the date and time when this game began.boolean
Checks whether this metadata contains the time control used for the game.static ZonedDateTime
parseDatetime
(String datetime) void
Add a new metadata value,value
, associated withkey
.void
Removes any metadata value associated withkey
.void
setEndTime
(TemporalAccessor datetime) Sets the date and time when this game was finished.void
setStartTime
(TemporalAccessor datetime) Sets the date and time when this game began.void
setTimeControl
(TimeControl timeControl) Sets the time control used for this game.static GameMetadata
toString()
-
Field Details
-
START_DATETIME_KEY
The key for storing when a game started.- See Also:
-
END_DATETIME_KEY
The key for storing when a game was finished.- See Also:
-
TIME_CONTROL_KEY
The key for storing the time control of a game.- See Also:
-
STANDARD_KEYS
Standard metadata keys that are commonly used.
-
-
Constructor Details
-
GameMetadata
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
-
copy
Creates a copy of this metadata.- Returns:
- A copy of this metadata.
-
getAll
Retrieves a copy of all the metadata stored.- Returns:
- A copy of all the metadata stored.
-
has
Checks whether there is any metadata associated withkey
.- Parameters:
key
- The metadata key to check.- Returns:
- Whether there is any metadata associated with
key
.
-
get
Get the metadata value associated withkey
, ornull
if there is no value associated with the key.- Parameters:
key
- The metadata key to retrieve.- Returns:
- The metadata value associated with
key
, or elsenull
.
-
remove
Removes any metadata value associated withkey
.- Parameters:
key
- The metadata key to remove.
-
clear
public void clear()Removes all metadata. -
put
Add a new metadata value,value
, associated withkey
.- 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
Gets the date and time when this game began, ornull
if no end time is included in this game's metadata.- Returns:
- The date and time when this game began,
or else
null
.
-
setStartTime
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
Gets the date and time when this game was finished, ornull
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
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
Gets the time control used for this game, ornull
if no time control was included in this game's metadata.- Returns:
- The time control used for this game, or else
null
.
-
setTimeControl
Sets the time control used for this game.- Parameters:
timeControl
- The time control used for this game.
-
equals
-
toString
-
parseDatetime
-
formatDatetime
-