Class UUIDManager

java.lang.Object
org.gcube.informationsystem.utils.UUIDManager

public final class UUIDManager extends Object
Manages reserved UUIDs and provides validation and generation of valid UUIDs.
Author:
Luca Frosini (ISTI - CNR)
  • Method Details

    • getInstance

      public static UUIDManager getInstance()
      Returns the singleton instance of the UUIDManager.
      Returns:
      The UUIDManager instance.
    • isReservedUUID

      public boolean isReservedUUID(UUID uuid)
      Checks if a UUID is reserved.
      Parameters:
      uuid - The UUID to check.
      Returns:
      true if the UUID is reserved, false otherwise.
    • isReservedUUID

      public boolean isReservedUUID(String uuid)
      Checks if a UUID string is reserved.
      Parameters:
      uuid - The UUID string to check.
      Returns:
      true if the UUID is reserved, false otherwise.
    • getAllReservedUUIDAsStrings

      public Set<String> getAllReservedUUIDAsStrings()
      Returns a set of all reserved UUIDs as strings.
      Returns:
      A set of reserved UUID strings.
    • getAllReservedUUID

      public Set<UUID> getAllReservedUUID()
      Returns a set of all reserved UUIDs.
      Returns:
      A set of reserved UUIDs.
    • generateValidUUID

      public UUID generateValidUUID()
      Generates a valid (non-reserved) UUID.
      Returns:
      A new valid UUID.
    • generateValidUUID

      public UUID generateValidUUID(UUID uuid)
      Generates a valid (non-reserved) UUID, optionally starting from a given UUID.
      Parameters:
      uuid - The UUID to start with, or null to generate a new random UUID.
      Returns:
      A valid UUID.
    • validateUUID

      public UUID validateUUID(UUID uuid) throws Exception
      Validates a UUID, throwing an exception if it is reserved.
      Parameters:
      uuid - The UUID to validate.
      Returns:
      The validated UUID.
      Throws:
      Exception - if the UUID is reserved.