Overrode equals and hashcode in RouteIdentifierImpl 16/5316/10
authorAbhishek Kumar <abhishk2@cisco.com>
Fri, 14 Feb 2014 00:25:41 +0000 (16:25 -0800)
committerTony Tkacik <ttkacik@cisco.com>
Tue, 4 Mar 2014 09:05:40 +0000 (09:05 +0000)
Updated pom to reflect correct dependency version

Change-Id: Ie88cecec686a5c542f8d3edcc99e895ecbf39c3b
Signed-off-by: Abhishek Kumar <abhishk2@cisco.com>
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/RemoteRpcProvider.java
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/sal/connector/remoterpc/dto/RouteIdentifierImpl.java

index 639e31d..16e7200 100644 (file)
@@ -279,7 +279,7 @@ public class RemoteRpcProvider implements
       for (RpcRoutingContext context : changes.keySet()){
         routeId = new RouteIdentifierImpl();
         routeId.setType(context.getRpc());
-        routeId.setContext(context.getContext());
+        //routeId.setContext(context.getContext());
 
         for (InstanceIdentifier instanceId : changes.get(context)){
           routeId.setRoute(instanceId);
index ec6a1a9..0b26727 100644 (file)
@@ -48,4 +48,39 @@ public class RouteIdentifierImpl implements RpcRouter.RouteIdentifier<QName, QNa
   public void setRoute(InstanceIdentifier route) {
     this.route = route;
   }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+
+    RouteIdentifierImpl that = (RouteIdentifierImpl) o;
+
+    if (context == null){
+      if (that.getContext() != null)  return false;
+    }else
+      if (!context.equals(that.context)) return false;
+
+    if (route == null){
+      if (that.getRoute() != null) return false;
+    }else
+      if (!route.equals(that.route)) return false;
+
+    if (type == null){
+      if (that.getType() != null) return false;
+    }else
+      if (!type.equals(that.type)) return false;
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    int prime = 31;
+    int result = 0;
+    result = prime * result + (context == null ? 0:context.hashCode());
+    result = prime * result + (type    == null ? 0:type.hashCode());
+    result = prime * result + (route   == null ? 0:route.hashCode());
+    return result;
+  }
 }