Package org.keycloak.models.map.common
Class UuidValidator
- java.lang.Object
-
- org.keycloak.models.map.common.UuidValidator
-
public class UuidValidator extends Object
Utility class for validating and converting UUIDs.- Author:
- Stefan Guilhen
-
-
Field Summary
Fields Modifier and Type Field Description protected static Pattern
UUID_REGEX_PATTERN
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
isValid(String id)
Validates that the specifiedid
is aUUID
.static String
validateAndConvert(String id)
Validates that the specifiedid
is aUUID
.
-
-
-
Field Detail
-
UUID_REGEX_PATTERN
protected static final Pattern UUID_REGEX_PATTERN
-
-
Method Detail
-
isValid
public static boolean isValid(String id)
Validates that the specifiedid
is aUUID
.- Parameters:
id
- theid
to be validated.- Returns:
true
if theid
is aUUID
;false
otherwise.
-
validateAndConvert
public static String validateAndConvert(String id)
Validates that the specifiedid
is aUUID
. If it is, theid
itself is returned. Otherwise, it is discarded and a newUUID
is created and returned.- Parameters:
id
- theid
to be validated.- Returns:
- the
id
itself if it is a validUUID
, or a new generatedUUID
.
-
-