Package ai.bizone.shortuuid
Class UuidConverter
java.lang.Object
ai.bizone.shortuuid.UuidConverter
UuidConverter is a class that can be used to convert UUIDs to and from different representations.
Including generation of named UUIDs (v3 and v5).
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic UUIDfromBase64(String base64) Convert a UUID to a Base64 string.static UUIDfromBigInteger(BigInteger uuidAsBigInt) Convert a UUID to a BigInteger.static UUIDnamedByVersion(int version, String name) Generate a name-based UUID (v3 or v5) using the specified version and name.static UUIDnamedByVersion(int version, UUID namespace, String name) Generate a name-based UUID (v3 or v5) using the specified version, namespace, and name.static StringConvert a UUID to a Base64 string.static BigIntegertoBigInteger(UUID uuid) Convert a UUID to a BigInteger.static UUIDtryParseUUID(String suspectedUUID) Try to parse a string as a UUID.
-
Field Details
-
BASE64_URL_ENCODER
-
-
Constructor Details
-
UuidConverter
public UuidConverter()
-
-
Method Details
-
tryParseUUID
Try to parse a string as a UUID.- Parameters:
suspectedUUID- String to be parsed- Returns:
- a UUID or null
-
toBigInteger
Convert a UUID to a BigInteger.- Parameters:
uuid- (required)- Returns:
- a BigInteger
-
toBase64
Convert a UUID to a Base64 string.- Parameters:
uuid- (required)- Returns:
- a Base64 string
-
fromBigInteger
Convert a UUID to a BigInteger.- Parameters:
uuidAsBigInt- (required)- Returns:
- a UUID
-
fromBase64
Convert a UUID to a Base64 string.- Parameters:
base64- (required)- Returns:
- a UUID
-
namedByVersion
Generate a name-based UUID (v3 or v5) using the specified version and name.- Parameters:
version- 3 or 5name- (required)- Returns:
- a name-based UUID
-
namedByVersion
Generate a name-based UUID (v3 or v5) using the specified version, namespace, and name.- Parameters:
version- 3 or 5namespace- (optional)name- (required)- Returns:
- a name-based UUID
-