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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionInstantiates 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 TypeMethodDescriptionvoidclear()Removes all metadata.copy()Creates a copy of this metadata.booleanstatic StringformatDatetime(TemporalAccessor datetime) Get the metadata value associated withkey, ornullif 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, ornullif no end time is included in this game's metadata.Gets the date and time when this game began, ornullif no end time is included in this game's metadata.Gets the time control used for this game, ornullif no time control was included in this game's metadata.booleanChecks whether there is any metadata associated withkey.booleanChecks whether this metadata contains the date and time when this game was finished.booleanChecks whether this metadata contains the date and time when this game began.booleanChecks whether this metadata contains the time control used for the game.static ZonedDateTimeparseDatetime(String datetime) voidAdd a new metadata value,value, associated withkey.voidRemoves any metadata value associated withkey.voidsetEndTime(TemporalAccessor datetime) Sets the date and time when this game was finished.voidsetStartTime(TemporalAccessor datetime) Sets the date and time when this game began.voidsetTimeControl(TimeControl timeControl) Sets the time control used for this game.static GameMetadatatoString()
-
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, ornullif 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, ornullif 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, ornullif 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, ornullif 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
-