Package org.kiwiproject.base
Class UUIDs
- java.lang.Object
-
- org.kiwiproject.base.UUIDs
-
-
Constructor Summary
Constructors Constructor Description UUIDs()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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 StringrandomUUIDString()Creates a new type 4 (pseudo randomly generated) UUID, and then returns it as a string.
-
-
-
Method Detail
-
randomUUIDString
public static String 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:
UUID.randomUUID()
-
isValidUUID
public static boolean isValidUUID(String value)
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:
UUID
-
isValidUUIDAllowingNil
public static boolean isValidUUIDAllowingNil(String value)
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:
UUID
-
-