Class IdGen

java.lang.Object
net.targetr.rc.util.IdGen

public class IdGen extends Object
Generates new IDs for rooms and clients.
Author:
Dr Michael Gardiner
  • Constructor Details

    • IdGen

      public IdGen()
      Constructs a new IdGen.
  • Method Details

    • createClientId

      public static String 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

      public static String 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

      public static boolean isValidRoomId(String id)
      Accepts room IDs of 4 to 11 ASCII letters, digits or hyphens. Validation permits custom IDs beyond the generated XXXX-XXXX format.
      Parameters:
      id - the string to validate
      Returns:
      true if the non-null ID has an accepted length and characters
    • isValidClientId

      public static boolean isValidClientId(String id)
      Accepts client IDs of exactly eight ASCII letters, digits or hyphens.
      Parameters:
      id - the string to validate
      Returns:
      true if the non-null ID has an accepted length and characters