Cleanup the implementation of class TopologyEvent and associated classes.

The major addition is the new method TopologyEvent.getEventType() that
returns the type of the event: SWITCH, PORT, LINK, HOST, MASTERSHIP

* Refactor and move around the implementation of methods like
  hashCode() equals() and toString()

* Remove method getID() from classes MastershipEvent, SwitchEvent, PortEvent
  LinkEvent, HostEvent, and keep it only in TopologyEvent where it is
  actually needed.

* Changed class TopologyElement to abstract, and added two abstract
  methods: getOriginDpid() and getIDasByteBuffer() which are already
  implemented by all FooEvent derived classes.

No functional changes.

Change-Id: I62f4723cb3f4b519f365c04e7b736abda9b1973b
diff --git a/src/main/java/net/onrc/onos/core/topology/PortEvent.java b/src/main/java/net/onrc/onos/core/topology/PortEvent.java
index 9907a19..b4b0b1b 100644
--- a/src/main/java/net/onrc/onos/core/topology/PortEvent.java
+++ b/src/main/java/net/onrc/onos/core/topology/PortEvent.java
@@ -95,48 +95,6 @@
         return id.getPortNumber();
     }
 
-    /**
-     * Gets the event origin DPID.
-     *
-     * @return the event origin DPID.
-     */
-    public Dpid getOriginDpid() {
-        return this.id.getDpid();
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) {
-            return true;
-        }
-
-        if (o == null) {
-            return false;
-        }
-
-        if (getClass() != o.getClass()) {
-            return false;
-        }
-        PortEvent other = (PortEvent) o;
-
-        // compare attributes
-        if (!super.equals(o)) {
-            return false;
-        }
-
-        return Objects.equals(this.id, other.id);
-    }
-
-    @Override
-    public int hashCode() {
-        return 31 * super.hashCode() + Objects.hashCode(id);
-    }
-
-    @Override
-    public String toString() {
-        return "[PortEvent " + getDpid() + "@" + getPortNumber() + "]";
-    }
-
     public static final int PORTID_BYTES = SwitchEvent.SWITCHID_BYTES + 2 + 8;
 
     public static ByteBuffer getPortID(Dpid dpid, PortNumber number) {
@@ -157,11 +115,42 @@
                 .putChar('P').putLong(number).flip();
     }
 
-    public byte[] getID() {
-        return getIDasByteBuffer().array();
+    @Override
+    public Dpid getOriginDpid() {
+        return this.id.getDpid();
     }
 
+    @Override
     public ByteBuffer getIDasByteBuffer() {
         return getPortID(getDpid(), getPortNumber());
     }
+
+    @Override
+    public int hashCode() {
+        return 31 * super.hashCode() + Objects.hashCode(id);
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+
+        // Compare attributes
+        if (!super.equals(o)) {
+            return false;
+        }
+
+        PortEvent other = (PortEvent) o;
+        return Objects.equals(this.id, other.id);
+    }
+
+    @Override
+    public String toString() {
+        return "[PortEvent " + getDpid() + "@" + getPortNumber() + "]";
+    }
 }