Package org.apache.kafka.common
Class Uuid
java.lang.Object
org.apache.kafka.common.Uuid
- All Implemented Interfaces:
- Comparable<Uuid>
This class defines an immutable universally unique identifier (UUID). It represents a 128-bit value.
 More specifically, the random UUIDs generated by this class are variant 2 (Leach-Salz) version 4 UUIDs.
 This is the same type of UUID as the ones generated by java.util.UUID. The toString() method prints
 using the base64 string encoding. Likewise, the fromString method expects a base64 string encoding.
- 
Field SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionUuid(long mostSigBits, long leastSigBits) Constructs a 128-bit type 4 UUID where the first long represents the most significant 64 bits and the second long represents the least significant 64 bits.
- 
Method SummaryModifier and TypeMethodDescriptionintbooleanReturns true iff obj is another Uuid represented by the same two long values.static UuidfromString(String str) Creates a UUID based on a base64 string encoding used in the toString() method.longReturns the least significant bits of the UUID's 128 value.longReturns the most significant bits of the UUID's 128 value.inthashCode()Returns a hash code for this UUIDstatic UuidStatic factory to retrieve a type 4 (pseudo randomly generated) UUID.static Uuid[]Convert a list of Uuid to an array of Uuid.Convert an array of Uuids to a list of Uuid.toString()Returns a base64 string encoding of the UUID.
- 
Field Details- 
ONE_UUIDA reserved UUID. Will never be returned by the randomUuid method.
- 
METADATA_TOPIC_IDA UUID for the metadata topic in KRaft mode. Will never be returned by the randomUuid method.
- 
ZERO_UUIDA UUID that represents a null or empty UUID. Will never be returned by the randomUuid method.
- 
RESERVEDThe set of reserved UUIDs that will never be returned by the randomUuid method.
 
- 
- 
Constructor Details- 
Uuidpublic Uuid(long mostSigBits, long leastSigBits) Constructs a 128-bit type 4 UUID where the first long represents the most significant 64 bits and the second long represents the least significant 64 bits.
 
- 
- 
Method Details- 
randomUuidStatic factory to retrieve a type 4 (pseudo randomly generated) UUID. This will not generate a UUID equal to 0, 1, or one whose string representation starts with a dash ("-")
- 
getMostSignificantBitspublic long getMostSignificantBits()Returns the most significant bits of the UUID's 128 value.
- 
getLeastSignificantBitspublic long getLeastSignificantBits()Returns the least significant bits of the UUID's 128 value.
- 
equalsReturns true iff obj is another Uuid represented by the same two long values.
- 
hashCodepublic int hashCode()Returns a hash code for this UUID
- 
toStringReturns a base64 string encoding of the UUID.
- 
fromStringCreates a UUID based on a base64 string encoding used in the toString() method.
- 
compareTo- Specified by:
- compareToin interface- Comparable<Uuid>
 
- 
toArrayConvert a list of Uuid to an array of Uuid.- Parameters:
- list- The input list
- Returns:
- The output array
 
- 
toListConvert an array of Uuids to a list of Uuid.- Parameters:
- array- The input array
- Returns:
- The output list
 
 
-