Class UUIDUtil

java.lang.Object
com.fasterxml.uuid.impl.UUIDUtil

public class UUIDUtil extends Object
  • Field Details

  • Constructor Details

    • UUIDUtil

      public UUIDUtil()
  • Method Details

    • nilUUID

      public static UUID nilUUID()
      Accessor for so-call "Nil UUID" (see RFC 9562, #5.9; one that is all zeroes.
      Returns:
      "Nil" UUID instance
      Since:
      4.1
    • maxUUID

      public static UUID maxUUID()
      Accessor for so-call "Max UUID" (see RFC-9562, #5.10); one that is all one bits
      Returns:
      "Nil" UUID instance
      Since:
      4.1
    • uuid

      public static UUID uuid(String id)
      Factory method for creating UUIDs from the canonical string representation.
      Parameters:
      id - String that contains the canonical representation of the UUID to build; 36-char string (see UUID specs for details). Hex-chars may be in upper-case too; UUID class will always output them in lowercase.
    • uuid

      public static UUID uuid(byte[] bytes)
      Factory method for constructing UUID instance from given 16 bytes. NOTE: since absolutely no validation is done for contents, this method should only be used if contents are known to be valid.
    • uuid

      public static UUID uuid(byte[] bytes, int offset)
      Factory method for constructing UUID instance from given 16 bytes. NOTE: since absolutely no validation is done for contents, this method should only be used if contents are known to be valid.
      Parameters:
      bytes - Array that contains sequence of 16 bytes that contain a valid UUID
      offset - Offset of the first of 16 bytes
    • constructUUID

      public static UUID constructUUID(UUIDType type, byte[] uuidBytes)
      Helper method for constructing UUID instances with appropriate type
    • constructUUID

      public static UUID constructUUID(UUIDType type, long l1, long l2)
    • initUUIDFirstLong

      public static long initUUIDFirstLong(long l1, UUIDType type)
    • initUUIDFirstLong

      public static long initUUIDFirstLong(long l1, int rawType)
    • initUUIDSecondLong

      public static long initUUIDSecondLong(long l2)
    • typeOf

      public static UUIDType typeOf(UUID uuid)
      Method for determining which type of UUID given UUID is. Returns null if type can not be determined.
      Parameters:
      uuid - UUID to check
      Returns:
      Null if UUID is null or type can not be determined (== invalid UUID); otherwise type
    • asByteArray

      public static byte[] asByteArray(UUID uuid)
    • toByteArray

      public static void toByteArray(UUID uuid, byte[] buffer)
    • toByteArray

      public static void toByteArray(UUID uuid, byte[] buffer, int offset)
    • gatherLong

      protected static final long gatherLong(byte[] buffer, int offset)
    • extractTimestamp

      public static long extractTimestamp(UUID uuid)
      Extract 64-bit timestamp from time-based UUIDs (if time-based type); returns 0 for other types.
      Parameters:
      uuid - uuid timestamp to extract from
      Returns:
      Unix timestamp in milliseconds (since Epoch), or 0 if type does not support timestamps
      Since:
      5.0