Add getType to Topology interfaces.
Change-Id: If0726e99db224f790e66f0e8f8adca3864ff6f69
diff --git a/src/main/java/net/onrc/onos/core/topology/Device.java b/src/main/java/net/onrc/onos/core/topology/Device.java
index a3eaf8b..71eda74 100644
--- a/src/main/java/net/onrc/onos/core/topology/Device.java
+++ b/src/main/java/net/onrc/onos/core/topology/Device.java
@@ -14,7 +14,7 @@
* immutable object, or a copy of the original "SB" In-memory Topology.
*/
@JsonSerialize(using = DeviceSerializer.class)
-public interface Device {
+public interface Device extends ITopologyElement {
/**
* Get the device MAC address.
*
diff --git a/src/main/java/net/onrc/onos/core/topology/ITopologyElement.java b/src/main/java/net/onrc/onos/core/topology/ITopologyElement.java
new file mode 100644
index 0000000..b9ce0d3
--- /dev/null
+++ b/src/main/java/net/onrc/onos/core/topology/ITopologyElement.java
@@ -0,0 +1,16 @@
+package net.onrc.onos.core.topology;
+
+// TODO give me a better name.
+/**
+ * Interface common to Topology element interfaces.
+ */
+public interface ITopologyElement {
+
+ // TODO The term Type is a bit confusing, may rename to something like layer
+ /**
+ * Returns the type of topology element.
+ *
+ * @return the type of the topology element
+ */
+ public String getType();
+}
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 8cd7b82..f54ff51 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 extends StringAttributes {
+public interface Link extends ITopologyElement, StringAttributes {
/**
* Gets the source switch for the link.
*
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 a8df75f..0ca5cce 100644
--- a/src/main/java/net/onrc/onos/core/topology/Port.java
+++ b/src/main/java/net/onrc/onos/core/topology/Port.java
@@ -14,7 +14,7 @@
* Interface of Port object in the topology.
*/
@JsonSerialize(using = PortSerializer.class)
-public interface Port extends StringAttributes {
+public interface Port extends ITopologyElement, 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/Switch.java b/src/main/java/net/onrc/onos/core/topology/Switch.java
index f57de38..11f3f2c 100644
--- a/src/main/java/net/onrc/onos/core/topology/Switch.java
+++ b/src/main/java/net/onrc/onos/core/topology/Switch.java
@@ -14,7 +14,7 @@
* Interface of Switch object in the topology.
*/
@JsonSerialize(using = SwitchSerializer.class)
-public interface Switch extends StringAttributes {
+public interface Switch extends ITopologyElement, StringAttributes {
/**
* Gets the data path ID (dpid) of this switch.
diff --git a/src/main/java/net/onrc/onos/core/topology/TopologyObject.java b/src/main/java/net/onrc/onos/core/topology/TopologyObject.java
index 661f081..ccb266c 100644
--- a/src/main/java/net/onrc/onos/core/topology/TopologyObject.java
+++ b/src/main/java/net/onrc/onos/core/topology/TopologyObject.java
@@ -7,7 +7,7 @@
/**
* Base class for Topology Objects.
*/
-public abstract class TopologyObject {
+public abstract class TopologyObject implements ITopologyElement {
/**
* Topology instance this object belongs to.
@@ -30,6 +30,7 @@
*
* @return the type of the topology object
*/
+ @Override
public abstract String getType();