ea72238fbcb3aa6cc29621c76821d08a0eb4e158
[controller.git] / opendaylight / md-sal / sal-remoterpc-connector / src / main / java / org / opendaylight / controller / remote / rpc / RouteIdentifierImpl.java
1 /*
2  * Copyright (c) 2014 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.remote.rpc;
9
10 import org.opendaylight.controller.sal.connector.api.RpcRouter;
11 import org.opendaylight.yangtools.yang.common.QName;
12 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
13
14 import java.io.Serializable;
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   public RouteIdentifierImpl(QName context, QName type, InstanceIdentifier route) {
24     this.context = context;
25     this.type = type;
26     this.route = route;
27   }
28
29   @Override
30   public QName getContext() {
31     return this.context;
32   }
33
34   @Override
35   public QName getType() {
36     return this.type;
37   }
38
39   @Override
40   public InstanceIdentifier getRoute() {
41     return this.route;
42   }
43
44
45   @Override
46   public boolean equals(Object o) {
47     if (this == o) return true;
48     if (o == null || getClass() != o.getClass()) return false;
49
50     RouteIdentifierImpl that = (RouteIdentifierImpl) o;
51
52     if (context == null){
53       if (that.getContext() != null)  return false;
54     }else
55       if (!context.equals(that.context)) return false;
56
57     if (route == null){
58       if (that.getRoute() != null) return false;
59     }else
60       if (!route.equals(that.route)) return false;
61
62     if (type == null){
63       if (that.getType() != null) return false;
64     }else
65       if (!type.equals(that.type)) return false;
66
67     return true;
68   }
69
70   @Override
71   public int hashCode() {
72     int prime = 31;
73     int result = 0;
74     result = prime * result + (context == null ? 0:context.hashCode());
75     result = prime * result + (type    == null ? 0:type.hashCode());
76     result = prime * result + (route   == null ? 0:route.hashCode());
77     return result;
78   }
79
80   @Override
81   public String toString() {
82     return "RouteIdentifierImpl{" +
83         "context=" + context +
84         ", type=" + type +
85         ", route=" + route +
86         '}';
87   }
88 }