Better UUID support
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 1a3c0e5..0f196e2 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -7,6 +7,9 @@
     </properties>
     <body>
         <release version="1.17-SNAPSHOT" date="in Mercurial" description="Maintenance">
+            <action dev="asomov" type="fix" issue="306">
+                Better UUID support (2015-09-23)
+            </action>
             <action dev="asomov" type="add">
                 Use Polyglot Maven: add support for YAML POM (2015-09-10)
             </action>
diff --git a/src/main/java/org/yaml/snakeyaml/constructor/Constructor.java b/src/main/java/org/yaml/snakeyaml/constructor/Constructor.java
index 7790f18..5006e2b 100644
--- a/src/main/java/org/yaml/snakeyaml/constructor/Constructor.java
+++ b/src/main/java/org/yaml/snakeyaml/constructor/Constructor.java
@@ -31,6 +31,7 @@
 import java.util.SortedSet;
 import java.util.TreeMap;
 import java.util.TreeSet;
+import java.util.UUID;
 
 import org.yaml.snakeyaml.TypeDescription;
 import org.yaml.snakeyaml.error.YAMLException;
@@ -376,7 +377,7 @@
                     || type == Boolean.class || Date.class.isAssignableFrom(type)
                     || type == Character.class || type == BigInteger.class
                     || type == BigDecimal.class || Enum.class.isAssignableFrom(type)
-                    || Tag.BINARY.equals(node.getTag()) || Calendar.class.isAssignableFrom(type)) {
+                    || Tag.BINARY.equals(node.getTag()) || Calendar.class.isAssignableFrom(type) || type == UUID.class) {
                 // standard classes created directly
                 result = constructStandardJavaInstance(type, node);
             } else {
@@ -504,6 +505,8 @@
             } else if (Number.class.isAssignableFrom(type)) {
                 ConstructYamlNumber contr = new ConstructYamlNumber();
                 result = contr.construct(node);
+            }  else if (UUID.class == type) {
+                result = UUID.fromString(node.getValue());
             } else {
                 if (yamlConstructors.containsKey(node.getTag())) {
                     result = yamlConstructors.get(node.getTag()).construct(node);
diff --git a/src/main/java/org/yaml/snakeyaml/representer/SafeRepresenter.java b/src/main/java/org/yaml/snakeyaml/representer/SafeRepresenter.java
index 9927fa6..147e3af 100644
--- a/src/main/java/org/yaml/snakeyaml/representer/SafeRepresenter.java
+++ b/src/main/java/org/yaml/snakeyaml/representer/SafeRepresenter.java
@@ -28,6 +28,7 @@
 import java.util.Map;
 import java.util.Set;
 import java.util.TimeZone;
+import java.util.UUID;
 import java.util.regex.Pattern;
 
 import org.yaml.snakeyaml.error.YAMLException;
@@ -49,6 +50,7 @@
         this.representers.put(String.class, new RepresentString());
         this.representers.put(Boolean.class, new RepresentBoolean());
         this.representers.put(Character.class, new RepresentString());
+        this.representers.put(UUID.class, new RepresentUuid());
         this.representers.put(byte[].class, new RepresentByteArray());
 
         Represent primitiveArray = new RepresentPrimitiveArray();
@@ -415,4 +417,10 @@
     public void setTimeZone(TimeZone timeZone) {
         this.timeZone = timeZone;
     }
-}
\ No newline at end of file
+
+    protected class RepresentUuid implements Represent {
+        public Node representData(Object data) {
+            return representScalar(getTag(data.getClass(), new Tag(UUID.class)), data.toString());
+        }
+    }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue306/BeanWithId.java b/src/test/java/org/yaml/snakeyaml/issues/issue306/BeanWithId.java
new file mode 100644
index 0000000..40f849e
--- /dev/null
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue306/BeanWithId.java
@@ -0,0 +1,39 @@
+/**
+ * Copyright (c) 2008, http://www.snakeyaml.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.yaml.snakeyaml.issues.issue306;
+
+import java.util.UUID;
+
+public class BeanWithId {
+    private int value;
+    private UUID id;
+
+    public int getValue() {
+        return value;
+    }
+
+    public void setValue(int value) {
+        this.value = value;
+    }
+
+    public UUID getId() {
+        return id;
+    }
+
+    public void setId(UUID id) {
+        this.id = id;
+    }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue306/UuidSupportTest.java b/src/test/java/org/yaml/snakeyaml/issues/issue306/UuidSupportTest.java
new file mode 100644
index 0000000..63134b0
--- /dev/null
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue306/UuidSupportTest.java
@@ -0,0 +1,65 @@
+/**
+ * Copyright (c) 2008, http://www.snakeyaml.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.yaml.snakeyaml.issues.issue306;
+
+import org.junit.Test;
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.nodes.Tag;
+
+import java.util.UUID;
+
+import static org.junit.Assert.assertEquals;
+
+public class UuidSupportTest {
+
+    //TODO @Test
+    public void loadFromString() {
+        String str = UUID.randomUUID().toString();
+        Yaml yaml = new Yaml();
+        UUID uuid = (UUID) yaml.load(str);
+        assertEquals(str, uuid.toString());
+    }
+
+    @Test
+    public void loadFromBean() {
+        String input = Util.getLocalResource("issues/issue306-1.yaml");
+        Yaml yaml = new Yaml();
+        BeanWithId bean = (BeanWithId) yaml.loadAs(input, BeanWithId.class);
+        assertEquals("7f511847-781a-45df-9c8d-1e32e028b9b3", bean.getId().toString());
+    }
+
+    @Test
+    public void dumpUuid() {
+        UUID uuid = UUID.randomUUID();
+        Yaml yaml = new Yaml();
+        String output = yaml.dump(uuid);
+        assertEquals("!!java.util.UUID '" + uuid.toString() + "'\n", output);
+    }
+
+    @Test
+    public void dumpBean() {
+        BeanWithId bean = new BeanWithId();
+        bean.setValue(3);
+        UUID uuid = UUID.fromString("ac4877be-0c31-4458-a86e-0272efe1aaa8");
+        bean.setId(uuid);
+        Yaml yaml = new Yaml();
+        String output = yaml.dumpAs(bean, Tag.MAP, DumperOptions.FlowStyle.BLOCK);
+        String expected = Util.getLocalResource("issues/issue306-2.yaml");
+        assertEquals(expected, output);
+    }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue310/PropertyWithPrivateCostructorTest.java b/src/test/java/org/yaml/snakeyaml/issues/issue310/PropertyWithPrivateCostructorTest.java
index 97d2ac7..cb52762 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue310/PropertyWithPrivateCostructorTest.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue310/PropertyWithPrivateCostructorTest.java
@@ -42,7 +42,7 @@
     }
 
     @Test
-    public void laodFromString() {
+    public void loadFromString() {
 
         String yamlStr = "id: 123\n" + "income: 123456.78\n" + "name: Neo Anderson";
 
diff --git a/src/test/resources/issues/issue306-1.yaml b/src/test/resources/issues/issue306-1.yaml
new file mode 100644
index 0000000..eb237d6
--- /dev/null
+++ b/src/test/resources/issues/issue306-1.yaml
@@ -0,0 +1,2 @@
+value: 14
+id: 7f511847-781a-45df-9c8d-1e32e028b9b3
diff --git a/src/test/resources/issues/issue306-2.yaml b/src/test/resources/issues/issue306-2.yaml
new file mode 100644
index 0000000..6bd4916
--- /dev/null
+++ b/src/test/resources/issues/issue306-2.yaml
@@ -0,0 +1,2 @@
+id: !!java.util.UUID 'ac4877be-0c31-4458-a86e-0272efe1aaa8'
+value: 3