Package org.nuxeo.common.utils
Class IdUtils
- java.lang.Object
-
- org.nuxeo.common.utils.IdUtils
-
public final class IdUtils extends Object
Utils for identifier generation.- Author:
- Anahide Tchertchian
-
-
Field Summary
Fields Modifier and Type Field Description static String
UUID_TYPE_4_REGEXP
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
generateId(String s, String wordSeparator, boolean lower, int maxChars)
Generates an id from a non-null String.static long
generateLongId()
Generates an unique long identifier.static String
generateStringId()
Generates an unique string identifier.static boolean
isValidUUID(String uuid)
Check if a given string has the pattern for UUID type 4
-
-
-
Field Detail
-
UUID_TYPE_4_REGEXP
public static final String UUID_TYPE_4_REGEXP
- See Also:
- Constant Field Values
-
-
Method Detail
-
generateStringId
public static String generateStringId()
Generates an unique string identifier.
-
generateLongId
public static long generateLongId()
Generates an unique long identifier.
-
generateId
public static String generateId(String s, String wordSeparator, boolean lower, int maxChars)
Generates an id from a non-null String.Replaces accented characters from a string by their ascii equivalent, removes non alphanumerical characters and replaces spaces by the given wordSeparator character.
- Parameters:
s
- the original StringwordSeparator
- the word separator to use (usually '-')lower
- if lower is true, remove upper casemaxChars
- maximum longer of identifier characters- Returns:
- the identifier String
-
isValidUUID
public static boolean isValidUUID(String uuid)
Check if a given string has the pattern for UUID type 4- Since:
- 5.7
-
-