Merge "Created Sample Feature Test Class for Base Feature Repository"
[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 com.google.common.base.Preconditions;
11 import org.opendaylight.controller.sal.connector.api.RpcRouter;
12 import org.opendaylight.yangtools.yang.common.QName;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
14
15
16 import java.io.Serializable;
17
18 public class RouteIdentifierImpl implements RpcRouter.RouteIdentifier<QName, QName, YangInstanceIdentifier>,Serializable {
19   private static final long serialVersionUID = 1L;
20
21   private final QName context;
22   private final QName type;
23   private final YangInstanceIdentifier route;
24
25   public RouteIdentifierImpl(final QName context, final QName type, final YangInstanceIdentifier route) {
26     Preconditions.checkNotNull(type, "Rpc type should not be null");
27     this.context = context;
28     this.type = type;
29     this.route = route;
30   }
31
32   @Override
33   public QName getContext() {
34     return this.context;
35   }
36
37   @Override
38   public QName getType() {
39     return this.type;
40   }
41
42   @Override
43   public YangInstanceIdentifier getRoute() {
44     return this.route;
45   }
46
47
48   @Override
49   public boolean equals(Object o) {
50     if (this == o) return true;
51     if (o == null || getClass() != o.getClass()) return false;
52
53     RouteIdentifierImpl that = (RouteIdentifierImpl) o;
54
55     if (context == null){
56       if (that.getContext() != null)  return false;
57     }else
58       if (!context.equals(that.context)) return false;
59
60     if (route == null){
61       if (that.getRoute() != null) return false;
62     }else
63       if (!route.equals(that.route)) return false;
64
65     if (type == null){
66       if (that.getType() != null) return false;
67     }else
68       if (!type.equals(that.type)) return false;
69
70     return true;
71   }
72
73   @Override
74   public int hashCode() {
75     int prime = 31;
76     int result = 0;
77     result = prime * result + (context == null ? 0:context.hashCode());
78     result = prime * result + (type    == null ? 0:type.hashCode());
79     result = prime * result + (route   == null ? 0:route.hashCode());
80     return result;
81   }
82
83   @Override
84   public String toString() {
85     return "RouteIdentifierImpl{" +
86         "context=" + context +
87         ", type=" + type +
88         ", route=" + route +
89         '}';
90   }
91 }