Re-added config.version to config-module-archetype.
[controller.git] / opendaylight / md-sal / sal-remoterpc-connector / implementation / src / main / java / org / opendaylight / controller / sal / connector / remoterpc / dto / RouteIdentifierImpl.java
index 6c5e5fbf1163c398b40ae67c5777039b6b6e8eb4..53c7cc0b8ddca4cbb9fa95a2cb23acf8745f08fc 100644 (file)
@@ -7,18 +7,14 @@
  */
 package org.opendaylight.controller.sal.connector.remoterpc.dto;
 
-import org.codehaus.jackson.JsonNode;
-import org.codehaus.jackson.map.ObjectMapper;
+import java.io.Serializable;
+
 import org.opendaylight.controller.sal.connector.api.RpcRouter;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
 
-import java.io.Serializable;
-import java.net.URI;
-
 public class RouteIdentifierImpl implements RpcRouter.RouteIdentifier<QName, QName, InstanceIdentifier>,Serializable {
-
-  transient ObjectMapper mapper = new ObjectMapper();
+  private static final long serialVersionUID = 1L;
 
   private QName context;
   private QName type;
@@ -52,36 +48,46 @@ public class RouteIdentifierImpl implements RpcRouter.RouteIdentifier<QName, QNa
   }
 
   @Override
-  public String toString() {
-    try {
-      return mapper.writeValueAsString(this);
-    } catch (Throwable e) {
-      //do nothing
-    }
-
-    return super.toString();
-  }
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
 
-  public RpcRouter.RouteIdentifier fromString(String input)
-      throws Exception {
+    RouteIdentifierImpl that = (RouteIdentifierImpl) o;
 
-    JsonNode root = mapper.readTree(input);
-    this.context  = parseQName(root.get("context"));
-    this.type     = parseQName(root.get("type"));
+    if (context == null){
+      if (that.getContext() != null)  return false;
+    }else
+      if (!context.equals(that.context)) return false;
 
-    return this;
-  }
+    if (route == null){
+      if (that.getRoute() != null) return false;
+    }else
+      if (!route.equals(that.route)) return false;
 
-  private QName parseQName(JsonNode node){
-    if (node == null) return null;
+    if (type == null){
+      if (that.getType() != null) return false;
+    }else
+      if (!type.equals(that.type)) return false;
 
-    String namespace = (node.get("namespace") != null) ?
-                       node.get("namespace").asText()  : "";
+    return true;
+  }
 
-    String localName = (node.get("localName") != null) ?
-                       node.get("localName").asText() : "";
+  @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;
+  }
 
-    URI uri = URI.create(namespace);
-    return new QName(uri, localName);
+  @Override
+  public String toString() {
+    return "RouteIdentifierImpl{" +
+        "context=" + context +
+        ", type=" + type +
+        ", route=" + route +
+        '}';
   }
 }