Add string attributes to self-containd objects.

- Add common super class to *Event classes, which handles attributes.
- Add string attributes to *Event classes (ONOS-1564)
- Populate string attributes.
  Picked random attribute obtained from OF, just to initially populate attrs.
  Attributes to be used for each elements should be revisited later.
- *Impl class to use/reference self-contained objects
   prep-work for snapshot in mind.
- unified equals implementations
- Add unfrozen Copy constructor.
- Add freeze check to fixed attributes.
- Remove get*Impl which was not really adding value.

Change-Id: I10f9538f87d133a22237bd8ab97b8de421d3930b
diff --git a/src/main/java/net/onrc/onos/core/topology/SwitchEvent.java b/src/main/java/net/onrc/onos/core/topology/SwitchEvent.java
index de0fff6..b6246d4 100644
--- a/src/main/java/net/onrc/onos/core/topology/SwitchEvent.java
+++ b/src/main/java/net/onrc/onos/core/topology/SwitchEvent.java
@@ -7,28 +7,57 @@
 import java.util.Objects;
 
 import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.apache.commons.lang.Validate;
 
 /**
  * Self-contained Switch Object.
  * <p/>
- * TODO: We probably want common base class/interface for Self-Contained Event Object.
+ * TODO: Rename to match what it is. (Switch/Port/Link/Device)Snapshot?
+ * FIXME: Current implementation directly use this object as
+ *        Replication message, but should be sending update operation info.
  */
 @JsonSerialize(using = SwitchEventSerializer.class)
-public class SwitchEvent {
-    protected final Dpid dpid;
+public class SwitchEvent extends TopologyElement<SwitchEvent> {
+    private final Dpid dpid;
 
     /**
      * Default constructor for Serializer to use.
      */
     @Deprecated
-    public SwitchEvent() {
+    protected SwitchEvent() {
         dpid = null;
     }
 
+    /**
+     * Creates the switch object.
+     *
+     * @param dpid Dpid to identify this switch
+     */
+    public SwitchEvent(Dpid dpid) {
+        Validate.notNull(dpid);
+        this.dpid = dpid;
+    }
+
+    /**
+     * Create an unfrozen copy of given Object.
+     *
+     * @param original to make copy of.
+     */
+    public SwitchEvent(SwitchEvent original) {
+        super(original);
+        this.dpid = original.dpid;
+    }
+
+    // TODO remove me when ready
     public SwitchEvent(Long dpid) {
         this.dpid = new Dpid(dpid);
     }
 
+    /**
+     * Gets the DPID identifying this switch.
+     *
+     * @return DPID
+     */
     public Dpid getDpid() {
         return dpid;
     }
@@ -39,17 +68,26 @@
             return true;
         }
 
-        if (!(o instanceof SwitchEvent)) {
+        if (o == null) {
             return false;
         }
 
-        SwitchEvent that = (SwitchEvent) o;
-        return Objects.equals(this.dpid, that.dpid);
+        if (getClass() != o.getClass()) {
+            return false;
+        }
+        SwitchEvent other = (SwitchEvent) o;
+
+        // compare attributes
+        if (!super.equals(o)) {
+            return false;
+        }
+
+        return Objects.equals(this.dpid, other.dpid);
     }
 
     @Override
     public int hashCode() {
-        return Objects.hashCode(dpid);
+        return 31 * super.hashCode() + Objects.hashCode(dpid);
     }
 
     @Override
@@ -59,11 +97,16 @@
 
     public static final int SWITCHID_BYTES = 2 + 8;
 
+    public static ByteBuffer getSwitchID(Dpid dpid) {
+        return getSwitchID(dpid.value());
+    }
+
     public static ByteBuffer getSwitchID(Long dpid) {
         if (dpid == null) {
             throw new IllegalArgumentException("dpid cannot be null");
         }
-        return (ByteBuffer) ByteBuffer.allocate(SwitchEvent.SWITCHID_BYTES).putChar('S').putLong(dpid).flip();
+        return (ByteBuffer) ByteBuffer.allocate(SwitchEvent.SWITCHID_BYTES)
+                .putChar('S').putLong(dpid).flip();
     }
 
     public byte[] getID() {