From b3fd71263326bff3c5f1255d3709e28bc791805c Mon Sep 17 00:00:00 2001 From: minenash Date: Sun, 14 Jan 2018 17:28:53 -0500 Subject: Added isUUID --- src/com/redstoner/misc/Utils.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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(); + } } -- cgit v1.2.3