53c7cc0b8ddca4cbb9fa95a2cb23acf8745f08fc
[controller.git] / opendaylight / md-sal / sal-remoterpc-connector / implementation / src / main / java / org / opendaylight / controller / sal / connector / remoterpc / dto / RouteIdentifierImpl.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.sal.connector.remoterpc.dto;
9
10 import java.io.Serializable;
11
12 import org.opendaylight.controller.sal.connector.api.RpcRouter;
13 import org.opendaylight.yangtools.yang.common.QName;
14 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
15
16 public class RouteIdentifierImpl implements RpcRouter.RouteIdentifier<QName, QName, InstanceIdentifier>,Serializable {
17   private static final long serialVersionUID = 1L;
18
19   private QName context;
20   private QName type;
21   private InstanceIdentifier route;
22
23   @Override
24   public QName getContext() {
25     return this.context;
26   }
27
28   @Override
29   public QName getType() {
30     return this.type;
31   }
32
33   @Override
34   public InstanceIdentifier getRoute() {
35     return this.route;
36   }
37
38   public void setContext(QName context) {
39     this.context = context;
40   }
41
42   public void setType(QName type) {
43     this.type = type;
44   }
45
46   public void setRoute(InstanceIdentifier route) {
47     this.route = route;
48   }
49
50   @Override
51   public boolean equals(Object o) {
52     if (this == o) return true;
53     if (o == null || getClass() != o.getClass()) return false;
54
55     RouteIdentifierImpl that = (RouteIdentifierImpl) o;
56
57     if (context == null){
58       if (that.getContext() != null)  return false;
59     }else
60       if (!context.equals(that.context)) return false;
61
62     if (route == null){
63       if (that.getRoute() != null) return false;
64     }else
65       if (!route.equals(that.route)) return false;
66
67     if (type == null){
68       if (that.getType() != null) return false;
69     }else
70       if (!type.equals(that.type)) return false;
71
72     return true;
73   }
74
75   @Override
76   public int hashCode() {
77     int prime = 31;
78     int result = 0;
79     result = prime * result + (context == null ? 0:context.hashCode());
80     result = prime * result + (type    == null ? 0:type.hashCode());
81     result = prime * result + (route   == null ? 0:route.hashCode());
82     return result;
83   }
84
85   @Override
86   public String toString() {
87     return "RouteIdentifierImpl{" +
88         "context=" + context +
89         ", type=" + type +
90         ", route=" + route +
91         '}';
92   }
93 }