Add string attribute interfaces.

- Add interface definition to be used for UC1. (ONOS-1428, ONOS-1354, ONOS-1390)
- Added toString which was missing only on SwitchImpl.

Change-Id: I5a97d5132129213d78999e4f24917e5e5dbe4496
diff --git a/src/main/java/net/onrc/onos/core/topology/Link.java b/src/main/java/net/onrc/onos/core/topology/Link.java
index 768d290..f1fcae8 100644
--- a/src/main/java/net/onrc/onos/core/topology/Link.java
+++ b/src/main/java/net/onrc/onos/core/topology/Link.java
@@ -10,7 +10,7 @@
  * Interface of Link object in the topology.
  */
 @JsonSerialize(using = LinkSerializer.class)
-public interface Link {
+public interface Link extends StringAttributes {
     /**
      * Gets the source switch for the link.
      *
diff --git a/src/main/java/net/onrc/onos/core/topology/LinkImpl.java b/src/main/java/net/onrc/onos/core/topology/LinkImpl.java
index 7347172..5542e64 100644
--- a/src/main/java/net/onrc/onos/core/topology/LinkImpl.java
+++ b/src/main/java/net/onrc/onos/core/topology/LinkImpl.java
@@ -1,5 +1,8 @@
 package net.onrc.onos.core.topology;
 
+import java.util.Map;
+
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import net.onrc.onos.core.util.SwitchPort;
 
 /**
@@ -77,6 +80,28 @@
     }
 
     @Override
+    public String getStringAttribute(String attr) {
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    @Override
+    @SuppressFBWarnings(value = "RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE",
+       justification = "getStringAttribute might return null once implemented")
+    public String getStringAttribute(String attr, String def) {
+        final String v = getStringAttribute(attr);
+        if (v == null) {
+            return def;
+        } else {
+            return v;
+        }
+    }
+
+    @Override
+    public Map<String, String> getAllStringAttributes() {
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    @Override
     public String toString() {
         return String.format("%s --(cap:%f Mbps)--> %s",
                 getSrcPort().toString(),
diff --git a/src/main/java/net/onrc/onos/core/topology/Port.java b/src/main/java/net/onrc/onos/core/topology/Port.java
index 6adf1f4..af503bc 100644
--- a/src/main/java/net/onrc/onos/core/topology/Port.java
+++ b/src/main/java/net/onrc/onos/core/topology/Port.java
@@ -12,7 +12,7 @@
  * Interface of Port object in the topology.
  */
 @JsonSerialize(using = PortSerializer.class)
-public interface Port {
+public interface Port extends StringAttributes {
 
     /**
      * Gets the data path ID (dpid) of the switch, which this port is on.
diff --git a/src/main/java/net/onrc/onos/core/topology/PortImpl.java b/src/main/java/net/onrc/onos/core/topology/PortImpl.java
index e88d23b..5d46005 100644
--- a/src/main/java/net/onrc/onos/core/topology/PortImpl.java
+++ b/src/main/java/net/onrc/onos/core/topology/PortImpl.java
@@ -2,8 +2,10 @@
 
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.Map;
 import java.util.Set;
 
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import net.onrc.onos.core.util.SwitchPort;
 
 /**
@@ -107,6 +109,28 @@
     }
 
     @Override
+    public String getStringAttribute(String attr) {
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    @Override
+    @SuppressFBWarnings(value = "RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE",
+       justification = "getStringAttribute might return null once implemented")
+    public String getStringAttribute(String attr, String def) {
+        final String v = getStringAttribute(attr);
+        if (v == null) {
+            return def;
+        } else {
+            return v;
+        }
+    }
+
+    @Override
+    public Map<String, String> getAllStringAttributes() {
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    @Override
     public String toString() {
         return String.format("%d:%d",
                 getSwitch().getDpid(),
diff --git a/src/main/java/net/onrc/onos/core/topology/StringAttributes.java b/src/main/java/net/onrc/onos/core/topology/StringAttributes.java
new file mode 100644
index 0000000..89c5b5c
--- /dev/null
+++ b/src/main/java/net/onrc/onos/core/topology/StringAttributes.java
@@ -0,0 +1,32 @@
+package net.onrc.onos.core.topology;
+
+import java.util.Map;
+
+/**
+ * Interface for Elements with StringAttributes.
+ */
+public interface StringAttributes {
+    /**
+     * Gets the string attribute.
+     *
+     * @param attr attribute name
+     * @return attribute value or null
+     */
+    public String getStringAttribute(final String attr);
+
+    /**
+     * Gets the string attribute.
+     *
+     * @param attr attribute name
+     * @param def default value if {@code attr} did not exist
+     * @return attribute value or null
+     */
+    public String getStringAttribute(final String attr, final String def);
+
+    /**
+     * Gets all the string attributes.
+     *
+     * @return Immutable Map containing all the String attributes.
+     */
+    public Map<String, String> getAllStringAttributes();
+}
diff --git a/src/main/java/net/onrc/onos/core/topology/Switch.java b/src/main/java/net/onrc/onos/core/topology/Switch.java
index e3d6c19..9a4bf8c 100644
--- a/src/main/java/net/onrc/onos/core/topology/Switch.java
+++ b/src/main/java/net/onrc/onos/core/topology/Switch.java
@@ -12,7 +12,7 @@
  * Interface of Switch object in the topology.
  */
 @JsonSerialize(using = SwitchSerializer.class)
-public interface Switch {
+public interface Switch extends StringAttributes {
 
     /**
      * Gets the data path ID (dpid) of this switch.
diff --git a/src/main/java/net/onrc/onos/core/topology/SwitchImpl.java b/src/main/java/net/onrc/onos/core/topology/SwitchImpl.java
index ee0eebd..415b924 100644
--- a/src/main/java/net/onrc/onos/core/topology/SwitchImpl.java
+++ b/src/main/java/net/onrc/onos/core/topology/SwitchImpl.java
@@ -12,6 +12,8 @@
 import java.util.Map;
 import java.util.Set;
 
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
 /**
  * Switch Object stored in In-memory Topology.
  * <p/>
@@ -126,4 +128,31 @@
         }
         return links;
     }
+
+    @Override
+    public String getStringAttribute(String attr) {
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    @Override
+    @SuppressFBWarnings(value = "RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE",
+       justification = "getStringAttribute might return null once implemented")
+    public String getStringAttribute(String attr, String def) {
+        final String v = getStringAttribute(attr);
+        if (v == null) {
+            return def;
+        } else {
+            return v;
+        }
+    }
+
+    @Override
+    public Map<String, String> getAllStringAttributes() {
+        throw new UnsupportedOperationException("Not implemented yet");
+    }
+
+    @Override
+    public String toString() {
+        return dpid.toString();
+    }
 }