Pushed Switch Mastership Events into the Topology event channel.
Needed for ONOS-1729
For now those events are not used.

Also, added new TopologyElement attribute type: TYPE_ALL_LAYERS
which applies to the Mastership Events.

NOTE: Currently, those events are intercepted within the
Floodlight Controller.java class. The interception point might be moved
once it becomes clear whether the event origin should be the mastership
election mechanism or the "role change request" accepted by the switch.
In addition, the interception point needs to be moved/ported as appropriate
once we move to the newer 1.3 OpenFlow driver implementation and eventloop.

Change-Id: Iff06ed5aee867c428a8378e31f9d51dbe3e6b978
diff --git a/src/main/java/net/onrc/onos/core/topology/TopologyEvent.java b/src/main/java/net/onrc/onos/core/topology/TopologyEvent.java
index 81e261d..cdae99c 100644
--- a/src/main/java/net/onrc/onos/core/topology/TopologyEvent.java
+++ b/src/main/java/net/onrc/onos/core/topology/TopologyEvent.java
@@ -7,14 +7,15 @@
  * Self-contained Topology event Object
  * <p/>
  * TODO: For now the topology event contains one of the following events:
- * Switch, Port, Link, Host. In the future it will contain multiple events
- * in a single transaction.
+ * Switch, Port, Link, Host, Switch Mastership. In the future it will contain
+ * multiple events in a single transaction.
  */
 public class TopologyEvent {
-    SwitchEvent switchEvent = null;        // Set for Switch event
-    PortEvent portEvent = null;            // Set for Port event
-    LinkEvent linkEvent = null;            // Set for Link event
-    HostEvent hostEvent = null;        // Set for Host event
+    SwitchEvent switchEvent = null;             // Set for Switch event
+    PortEvent portEvent = null;                 // Set for Port event
+    LinkEvent linkEvent = null;                 // Set for Link event
+    HostEvent hostEvent = null;                 // Set for Host event
+    MastershipEvent mastershipEvent = null;     // Set for Mastership event
 
     /**
      * Default constructor.
@@ -59,6 +60,15 @@
     }
 
     /**
+     * Constructor for given Switch Mastership event.
+     *
+     * @param mastershipEvent the Switch Mastership event to use.
+     */
+    TopologyEvent(MastershipEvent mastershipEvent) {
+        this.mastershipEvent = mastershipEvent;
+    }
+
+    /**
      * Check if all events contained are equal.
      *
      * @param obj TopologyEvent to compare against
@@ -81,12 +91,14 @@
         return Objects.equals(switchEvent, other.switchEvent) &&
                 Objects.equals(portEvent, other.portEvent) &&
                 Objects.equals(linkEvent, other.linkEvent) &&
-                Objects.equals(hostEvent, other.hostEvent);
+                Objects.equals(hostEvent, other.hostEvent) &&
+                Objects.equals(mastershipEvent, other.mastershipEvent);
     }
 
     @Override
     public int hashCode() {
-        return Objects.hash(switchEvent, portEvent, linkEvent, hostEvent);
+        return Objects.hash(switchEvent, portEvent, linkEvent, hostEvent,
+                            mastershipEvent);
     }
 
     /**
@@ -108,6 +120,9 @@
         if (hostEvent != null) {
             return hostEvent.toString();
         }
+        if (mastershipEvent != null) {
+            return mastershipEvent.toString();
+        }
         return "[Empty TopologyEvent]";
     }
 
@@ -129,6 +144,9 @@
         if (hostEvent != null) {
             return hostEvent.getID();
         }
+        if (mastershipEvent != null) {
+            return mastershipEvent.getID();
+        }
         throw new IllegalStateException("Invalid TopologyEvent ID");
     }
 }