package org.opendaylight.controller.sal.connector.remoterpc.dto;
import java.io.Serializable;
-import java.net.URI;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
import org.opendaylight.controller.sal.connector.api.RpcRouter;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
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;
}
@Override
- public String toString() {
- try {
- return mapper.writeValueAsString(this);
- } catch (Throwable e) {
- //do nothing
- }
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
- return super.toString();
- }
+ RouteIdentifierImpl that = (RouteIdentifierImpl) o;
- public RpcRouter.RouteIdentifier fromString(String input)
- throws Exception {
+ if (context == null){
+ if (that.getContext() != null) return false;
+ }else
+ if (!context.equals(that.context)) return false;
- JsonNode root = mapper.readTree(input);
- this.context = parseQName(root.get("context"));
- this.type = parseQName(root.get("type"));
-
- 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 +
+ '}';
}
}