MastershipEvent carries RoleInfo as a subject

Change-Id: I8f850ad1f21bfbdc23fedda1a53f4ccedb1b8d32
diff --git a/core/api/src/main/java/org/onlab/onos/cluster/RoleInfo.java b/core/api/src/main/java/org/onlab/onos/cluster/RoleInfo.java
index 45b96ab..767884d 100644
--- a/core/api/src/main/java/org/onlab/onos/cluster/RoleInfo.java
+++ b/core/api/src/main/java/org/onlab/onos/cluster/RoleInfo.java
@@ -3,10 +3,11 @@
 import java.util.List;
 import java.util.Objects;
 
+import com.google.common.base.MoreObjects;
 import com.google.common.collect.ImmutableList;
 
 /**
- * A container for detailed role information for a device,
+ * An immutable container for role information for a device,
  * within the current cluster. Role attributes include current
  * master and a preference-ordered list of backup nodes.
  */
@@ -52,12 +53,9 @@
 
     @Override
     public String toString() {
-        final StringBuilder builder = new StringBuilder();
-        builder.append("master:").append(master).append(",");
-        builder.append("backups:");
-        for (NodeId n : backups) {
-            builder.append(" ").append(n);
-        }
-        return builder.toString();
+        return MoreObjects.toStringHelper(this.getClass())
+            .add("master", master)
+            .add("backups", backups)
+            .toString();
     }
 }
diff --git a/core/api/src/main/java/org/onlab/onos/mastership/MastershipEvent.java b/core/api/src/main/java/org/onlab/onos/mastership/MastershipEvent.java
index 9f75fc4..dcb2d95 100644
--- a/core/api/src/main/java/org/onlab/onos/mastership/MastershipEvent.java
+++ b/core/api/src/main/java/org/onlab/onos/mastership/MastershipEvent.java
@@ -1,6 +1,7 @@
 package org.onlab.onos.mastership;
 
 import org.onlab.onos.cluster.NodeId;
+import org.onlab.onos.cluster.RoleInfo;
 import org.onlab.onos.event.AbstractEvent;
 import org.onlab.onos.net.DeviceId;
 
@@ -9,9 +10,8 @@
  */
 public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceId> {
 
-    //do we worry about explicitly setting slaves/equals? probably not,
-    //to keep it simple
-    NodeId node;
+    //Contains master and standby information.
+    RoleInfo roleInfo;
 
     /**
      * Type of mastership events.
@@ -29,16 +29,16 @@
     }
 
     /**
-     * Creates an event of a given type and for the specified device, master,
-     * and the current time.
+     * Creates an event of a given type and for the specified device,
+     * role information, and the current time.
      *
      * @param type   device event type
      * @param device event device subject
-     * @param node master ID subject
+     * @param info mastership role information subject
      */
-    public MastershipEvent(Type type, DeviceId device, NodeId node) {
+    public MastershipEvent(Type type, DeviceId device, RoleInfo info) {
         super(type, device);
-        this.node = node;
+        this.roleInfo = info;
     }
 
     /**
@@ -50,9 +50,9 @@
      * @param master master ID subject
      * @param time   occurrence time
      */
-    public MastershipEvent(Type type, DeviceId device, NodeId master, long time) {
+    public MastershipEvent(Type type, DeviceId device, RoleInfo info, long time) {
         super(type, device, time);
-        this.node = master;
+        this.roleInfo = info;
     }
 
     /**
@@ -63,7 +63,17 @@
      *
      * @return node ID as a subject
      */
+    //XXX to-be removed - or keep for convenience?
     public NodeId node() {
-        return node;
+        return roleInfo.master();
+    }
+
+    /**
+     * Returns the current role state for the subject.
+     *
+     * @return RoleInfo associated with Device ID subject
+     */
+    public RoleInfo roleInfo() {
+        return roleInfo;
     }
 }