Add "type" attributes to Topology elements
Add type attributes to Topology elements (ONOS-1575, ONOS-1391)
- add "type" as String attributes
- add "type" to JSON representation
Change-Id: I0ab790cfd18eba17e352780b336e5cd49c6fcb1e
diff --git a/src/main/java/net/onrc/onos/core/topology/TopologyElement.java b/src/main/java/net/onrc/onos/core/topology/TopologyElement.java
index ceaf0fc..fc94c0a 100644
--- a/src/main/java/net/onrc/onos/core/topology/TopologyElement.java
+++ b/src/main/java/net/onrc/onos/core/topology/TopologyElement.java
@@ -18,7 +18,22 @@
* (Required to define a method returning itself's type)
*/
public class TopologyElement<T extends TopologyElement<T>>
- implements StringAttributes, UpdateStringAttributes {
+ implements ITopologyElement, StringAttributes, UpdateStringAttributes {
+
+ // TODO: Where should the attribute names be defined?
+ /**
+ * Attribute name for type.
+ */
+ public static final String TYPE = "type";
+ /**
+ * Attribute "type" value representing that the object belongs to Packet layer.
+ */
+ public static final String TYPE_PACKET = "packet";
+ /**
+ * Attribute "type" value representing that the object belongs to Optical layer.
+ */
+ public static final String TYPE_OPTICAL = "optical";
+
private boolean isFrozen = false;
@@ -151,4 +166,9 @@
this.stringAttributes.remove(attr);
}
+
+ @Override
+ public String getType() {
+ return getStringAttribute(TYPE, TYPE_PACKET);
+ }
}