Serializer for DefaultAnnotations. This allows Annotated objects to be correctly
used as keys in ConsistentMaps. Fixes ONOS-2128.

Change-Id: Ia21a25712351b99bc1b79dc231be8187cf3d3a0b
diff --git a/core/api/src/main/java/org/onosproject/net/DefaultAnnotations.java b/core/api/src/main/java/org/onosproject/net/DefaultAnnotations.java
index 4215d65..7c97ecd 100644
--- a/core/api/src/main/java/org/onosproject/net/DefaultAnnotations.java
+++ b/core/api/src/main/java/org/onosproject/net/DefaultAnnotations.java
@@ -21,6 +21,8 @@
 import java.util.Objects;
 import java.util.Set;
 
+import com.google.common.collect.Maps;
+
 import static com.google.common.base.Preconditions.checkNotNull;
 
 /**
@@ -59,6 +61,15 @@
     }
 
     /**
+     * Returns the annotations as a map.
+     *
+     * @return a copy of the contents of the annotations as a map.
+     */
+    public HashMap<String, String> asMap() {
+        return Maps.newHashMap(this.map);
+    }
+
+    /**
      * Creates a new set of annotations using clone of the specified hash map.
      *
      * @param map hash map of key/value pairs