Package net.targetr.rc
Class IdGen
java.lang.Object
net.targetr.rc.IdGen
Generates new IDs for rooms and clients.
- Author:
- Dr Michael Gardiner
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringGenerates a new random client ID.static StringGenerates a new random room ID.static booleanValidates whether a given string is a correctly formatted client ID.static booleanisValidRoomId(String id) Validates whether a given string is a correctly formatted room ID.
-
Constructor Details
-
IdGen
public IdGen()Constructs a new IdGen.
-
-
Method Details
-
createClientId
Generates a new random client ID. The ID format is XXXXXXXX where X represents a character from the allowed set.- Returns:
- a new randomly generated string representing a client ID
-
createRoomId
Generates a new random room ID. The ID format is XXXX-XXXX where X represents a character from the allowed set.- Returns:
- a new randomly generated string representing a room ID
-
isValidRoomId
Validates whether a given string is a correctly formatted room ID.- Parameters:
id- the string to validate- Returns:
- true if the ID matches the expected room ID format and contains only valid characters, false otherwise
-
isValidClientId
Validates whether a given string is a correctly formatted client ID.- Parameters:
id- the string to validate- Returns:
- true if the ID matches the expected client ID format and contains only valid characters, false otherwise
-