src/Pure/General/uuid.scala
changeset 69458 5655af3ea5bd
child 73133 497e11537d48
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Pure/General/uuid.scala	Thu Dec 13 15:21:34 2018 +0100
@@ -0,0 +1,20 @@
+/*  Title:      Pure/General/uuid.scala
+    Author:     Makarius
+
+Universally unique identifiers.
+*/
+
+package isabelle
+
+
+object UUID
+{
+  type T = java.util.UUID
+
+  def random(): T = java.util.UUID.randomUUID()
+  def random_string(): String = random().toString
+
+  def unapply(s: String): Option[T] =
+    try { Some(java.util.UUID.fromString(s)) }
+    catch { case _: IllegalArgumentException => None }
+}