Package org.kiwiproject.base
Class UUIDs
java.lang.Object
org.kiwiproject.base.UUIDs
Utility class for working with
UUID instances.-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisValidUUID(String value) Checks if thevalueis a valid UUID conforming to RFC 4122.static booleanisValidUUIDAllowingNil(String value) Checks if thevalueis a valid UUID conforming to RFC 4122 (including the Nil UUID).static StringCreates a new type 4 (pseudo randomly generated) UUID, and then returns it as a string.
-
Method Details
-
randomUUIDString
Creates a new type 4 (pseudo randomly generated) UUID, and then returns it as a string.- Returns:
- a new random UUID as a String
- See Also:
-
isValidUUID
Checks if thevalueis a valid UUID conforming to RFC 4122. The general form is 8-4-4-4-12 where all the digits are hexadecimal. Example:e94c302e-e684-4d72-9060-a66461f858d6Note specifically that this method does not support the Nil UUID and will always return false if given a Nil UUID.
This method has been tested with UUIDs generated using
UUID.randomUUID()andUUID.nameUUIDFromBytes(byte[]). It has also been tested with UUIDs created using the constructorUUID(long, long)with the caveat that the most and least significant bits came from valid type 3 and 4 UUIDs.- Parameters:
value- the string to check- Returns:
trueif a valid UUID,falseotherwise- See Also:
-
isValidUUIDAllowingNil
Checks if thevalueis a valid UUID conforming to RFC 4122 (including the Nil UUID). The general form is 8-4-4-4-12 where all the digits are hexadecimal. Example:e94c302e-e684-4d72-9060-a66461f858d6, or the nil UUID00000000-0000-0000-0000-000000000000.This method has been tested with UUIDs generated using
UUID.randomUUID()andUUID.nameUUIDFromBytes(byte[]). It has also been tested with UUIDs created using the constructorUUID(long, long)with the caveat that the most and least significant bits came from valid type 3 and 4 UUIDs.- Parameters:
value- the string to check- Returns:
trueif a valid UUID,falseotherwise- See Also:
-