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/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);
+ }
}