Package memeid
Class UUID
- java.lang.Object
-
- memeid.UUID
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
UUID.UnknownVersion
Not standard-version UUIDs.static class
UUID.V1
Version 1 UUIDs are those generated using a timestamp and the MAC address of the computer on which it was generated.static class
UUID.V2
DCE Security version, with embedded POSIX UIDs.static class
UUID.V3
Version 3 UUIDs are those generated by hashing a namespace identifier and name using MD5 as the hashing algorithm.static class
UUID.V4
Version 4 UUIDs are those generated using random numbers.static class
UUID.V5
Version 5 UUIDs are those generated by hashing a namespace identifier and name using SHA-1 as the hashing algorithm.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.UUID
asJava()
Returns thisUUID
as aUUID
.java.util.Optional<UUID.V1>
asV1()
java.util.Optional<UUID.V2>
asV2()
java.util.Optional<UUID.V3>
asV3()
java.util.Optional<UUID.V4>
asV4()
java.util.Optional<UUID.V5>
asV5()
int
compareTo(UUID o)
boolean
equals(java.lang.Object obj)
static UUID
from(long msb, long lsb)
Creates a validUUID
from twolong
values representing the most/least significant bits.static UUID
fromString(java.lang.String name)
Creates aUUID
from the string standard representation as described in thetoString()
method.static UUID
fromUUID(java.util.UUID juuid)
Creates a validUUID
from aUUID
.long
getLeastSignificantBits()
Returns the most significant 64 bits of this UUID's 128 bit value.long
getMostSignificantBits()
Returns the most significant 64 bits of this UUID's 128 bit value.int
hashCode()
boolean
isNil()
boolean
isV1()
boolean
isV2()
boolean
isV3()
boolean
isV4()
boolean
isV5()
java.lang.String
toString()
Returns aString
object representing thisUUID
.int
variant()
The variant field determines the layout of theUUID
.int
version()
The version number associated with thisUUID
.
-
-
-
Method Detail
-
from
public static UUID from(long msb, long lsb)
Creates a validUUID
from twolong
values representing the most/least significant bits.- Parameters:
msb
- Most significant bit inlong
representationlsb
- Least significant bit inlong
representation- Returns:
- a new
UUID
constructed from msb and lsb
-
fromUUID
public static UUID fromUUID(java.util.UUID juuid)
Creates a validUUID
from aUUID
.- Parameters:
juuid
- theUUID
- Returns:
- a valid
UUID
created from aUUID
-
fromString
public static UUID fromString(java.lang.String name)
Creates aUUID
from the string standard representation as described in thetoString()
method.- Parameters:
name
- A string that specifies aUUID
- Returns:
- A
UUID
with the specified value - Throws:
java.lang.IllegalArgumentException
- If name does not conform to the string representation as described intoString()
-
getMostSignificantBits
public long getMostSignificantBits()
Returns the most significant 64 bits of this UUID's 128 bit value.- Returns:
- The most significant 64 bits of this UUID's 128 bit value
-
getLeastSignificantBits
public long getLeastSignificantBits()
Returns the most significant 64 bits of this UUID's 128 bit value.- Returns:
- The most significant 64 bits of this UUID's 128 bit value
-
variant
public int variant()
The variant field determines the layout of theUUID
.The variant field consists of a variable number of the most significant bits of octet 8 of the
UUID
.The variant number has the following meaning:
- '''0''': Reserved for NCS backward compatibility
- '''2''': RFC-4122
- '''6''': Reserved, Microsoft Corporation backward compatibility
- '''7''': Reserved for future definition
Interoperability, in any form, with variants other than the one defined here is not guaranteed, and is not likely to be an issue in practice.
-
version
public int version()
The version number associated with thisUUID
. The version number describes how thisUUID
was generated.The version number has the following meaning:
- '''1''': Time-based UUID
- '''2''': DCE security UUID
- '''3''': Name-based UUID
- '''4''': Randomly generated UUID
- '''5''': The name-based version that uses SHA-1 hashing
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
compareTo
public int compareTo(UUID o)
- Specified by:
compareTo
in interfacejava.lang.Comparable<UUID>
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
Returns aString
object representing thisUUID
.The UUID string representation is as described by this BNF:
UUID = <time_low> "-" <time_mid> "-" <time_high_and_version> "-" <variant_and_sequence> "-" <node> time_low = 4*<hexOctet> time_mid = 2*<hexOctet> time_high_and_version = 2*<hexOctet> variant_and_sequence = 2*<hexOctet> node = 6*<hexOctet> hexOctet = <hexDigit><hexDigit> hexDigit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "a" | "b" | "c" | "d" | "e" | "f" | "A" | "B" | "C" | "D" | "E" | "F"
- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string representation of this
UUID
-
asV1
public java.util.Optional<UUID.V1> asV1()
-
asV2
public java.util.Optional<UUID.V2> asV2()
-
asV3
public java.util.Optional<UUID.V3> asV3()
-
asV4
public java.util.Optional<UUID.V4> asV4()
-
asV5
public java.util.Optional<UUID.V5> asV5()
-
isNil
public boolean isNil()
- Returns:
true
if thisUUID
is aNIL UUID
;false
otherwise
-
-