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/TopologyElement.java b/src/main/java/net/onrc/onos/core/topology/TopologyElement.java
index 81ecb1f..52304f4 100644
--- a/src/main/java/net/onrc/onos/core/topology/TopologyElement.java
+++ b/src/main/java/net/onrc/onos/core/topology/TopologyElement.java
@@ -1,5 +1,6 @@
 package net.onrc.onos.core.topology;
 
+import java.nio.ByteBuffer;
 import java.util.Collections;
 import java.util.Map;
 import java.util.Objects;
@@ -8,6 +9,8 @@
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
+import net.onrc.onos.core.util.Dpid;
+
 /**
  * Base class for Topology Elements.
  * <p/>
@@ -17,7 +20,7 @@
  * @param <T> Sub-class' type.
  *      (Required to define a method returning itself's type)
  */
-public class TopologyElement<T extends TopologyElement<T>>
+public abstract class TopologyElement<T extends TopologyElement<T>>
         implements ITopologyElement, StringAttributes, UpdateStringAttributes {
 
     // TODO: Where should the attribute names be defined?
@@ -208,4 +211,18 @@
     public AdminStatus getStatus() {
         return AdminStatus.valueOf(getStringAttribute(ELEMENT_ADMIN_STATUS));
     }
+
+    /**
+     * Gets the topology event origin DPID.
+     *
+     * @return the topology event origin DPID.
+     */
+    abstract Dpid getOriginDpid();
+
+    /**
+     * Gets the topology event ID as a ByteBuffer.
+     *
+     * @return the topology event ID as a ByteBuffer.
+     */
+    abstract ByteBuffer getIDasByteBuffer();
 }