Small improvements to SDN-IP classes.

 * SwitchPort is now immutable so we can remove the copy from Interface
 * Implement equals and hashcode in RibUpdate

Change-Id: I6b8375b6e4b38d42c41850536d65996233fa5856
diff --git a/src/main/java/net/onrc/onos/apps/sdnip/Interface.java b/src/main/java/net/onrc/onos/apps/sdnip/Interface.java
index 4052e81..e1a06c0 100644
--- a/src/main/java/net/onrc/onos/apps/sdnip/Interface.java
+++ b/src/main/java/net/onrc/onos/apps/sdnip/Interface.java
@@ -2,8 +2,6 @@
 
 import java.net.InetAddress;
 
-import net.onrc.onos.core.util.Dpid;
-import net.onrc.onos.core.util.PortNumber;
 import net.onrc.onos.core.util.SwitchPort;
 
 import org.codehaus.jackson.annotate.JsonCreator;
@@ -33,6 +31,7 @@
     private final short port;
     private final InetAddress ipAddress;
     private final int prefixLength;
+    private final SwitchPort switchPort;
 
     /**
      * Class constructor used by the JSON library to create an object.
@@ -54,6 +53,7 @@
         this.port = port;
         this.ipAddress = InetAddresses.forString(ipAddress);
         this.prefixLength = prefixLength;
+        switchPort = new SwitchPort(this.dpid, this.port);
     }
 
     /**
@@ -71,9 +71,7 @@
      * @return the switch port
      */
     public SwitchPort getSwitchPort() {
-        //TODO SwitchPort, Dpid and Port are mutable, but they could probably
-        //be made immutable which would prevent the need to copy
-        return new SwitchPort(new Dpid(dpid), PortNumber.uint16(port));
+        return switchPort;
     }
 
     /**
@@ -120,7 +118,7 @@
 
         Interface otherInterface = (Interface) other;
 
-        //Don't check switchPort as it's comprised of dpid and port
+        // Don't check switchPort as it is comprised of dpid and port
         return (name.equals(otherInterface.name)) &&
                 (dpid == otherInterface.dpid) &&
                 (port == otherInterface.port) &&
diff --git a/src/main/java/net/onrc/onos/apps/sdnip/RibUpdate.java b/src/main/java/net/onrc/onos/apps/sdnip/RibUpdate.java
index 040b079..614bffe 100644
--- a/src/main/java/net/onrc/onos/apps/sdnip/RibUpdate.java
+++ b/src/main/java/net/onrc/onos/apps/sdnip/RibUpdate.java
@@ -1,5 +1,8 @@
 package net.onrc.onos.apps.sdnip;
 
+import java.util.Objects;
+
+
 /**
  * Represents a route update received from BGPd. An update has an operation
  * describing whether the update is adding a route or revoking a route. It also
@@ -70,4 +73,21 @@
     public RibEntry getRibEntry() {
         return ribEntry;
     }
+
+    @Override
+    public boolean equals(Object o) {
+        if (!(o instanceof RibUpdate)) {
+            return false;
+        }
+
+        RibUpdate otherUpdate = (RibUpdate) o;
+        return Objects.equals(this.operation, otherUpdate.operation)
+                && Objects.equals(this.prefix, otherUpdate.prefix)
+                && Objects.equals(this.ribEntry, otherUpdate.ribEntry);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(operation, prefix, ribEntry);
+    }
 }