mirror of
https://github.com/Minestom/Minestom.git
synced 2024-06-28 07:24:57 +02:00
24 lines
663 B
Java
24 lines
663 B
Java
|
package net.minestom.server.utils;
|
||
|
|
||
|
import java.util.UUID;
|
||
|
import java.util.regex.Pattern;
|
||
|
|
||
|
/**
|
||
|
* An utilities class for {@link UUID}
|
||
|
*/
|
||
|
public class UniqueIdUtils {
|
||
|
|
||
|
public static final Pattern UNIQUE_ID_PATTERN = Pattern.compile("\\b[0-9a-f]{8}\\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\\b[0-9a-f]{12}\\b");
|
||
|
|
||
|
/**
|
||
|
* Checks whether the {@code input} string is an {@link UUID}
|
||
|
*
|
||
|
* @param input The input string to be checked
|
||
|
* @return {@code true} if the input an unique identifier, otherwise {@code false}
|
||
|
*/
|
||
|
public static boolean isUniqueId(String input) {
|
||
|
return input.matches(UNIQUE_ID_PATTERN.pattern());
|
||
|
}
|
||
|
|
||
|
}
|