diff options
author | minenash <enderbros.minenash@gmail.com> | 2018-01-14 17:28:53 -0500 |
---|---|---|
committer | minenash <enderbros.minenash@gmail.com> | 2018-01-14 17:28:53 -0500 |
commit | b3fd71263326bff3c5f1255d3709e28bc791805c (patch) | |
tree | e74578d0ea8660155ec7e1e782541cb411559166 | |
parent | e0101bbd1ddf0a8a85bc3362aa7cb8e362f4a30a (diff) |
Added isUUID
-rw-r--r-- | src/com/redstoner/misc/Utils.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/com/redstoner/misc/Utils.java b/src/com/redstoner/misc/Utils.java index 0902382..d5415f4 100644 --- a/src/com/redstoner/misc/Utils.java +++ b/src/com/redstoner/misc/Utils.java @@ -4,6 +4,7 @@ import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Date; import java.util.List; +import java.util.regex.Pattern; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; @@ -20,6 +21,9 @@ public final class Utils /** The @SimpleDateFormat used for getting the current date. */ public static SimpleDateFormat dateFormat = new SimpleDateFormat("[yyyy-MM-dd HH:mm:ss]"); + /** The Pattern for a UUID*/ + private static final Pattern UUID_pattern = Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"); + /** Hidden constructor. Do not instantiate UTILS classes! :) */ private Utils() {} @@ -129,4 +133,14 @@ public final class Utils id = "CONSOLE"; return id; } + + /** Checks if the string is an UUID. + * + * @param toCheck String to check. + * @return if the string is an UUID. + */ + public static boolean isUUID(String toCheck) + { + return UUID_pattern.matcher(toCheck).matches(); + } } |