Fix checkstyle violations in sal-dom-api
[controller.git] / opendaylight / md-sal / sal-dom-api / src / main / java / org / opendaylight / controller / sal / core / api / RpcRoutingContext.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.sal.core.api;
9
10 import java.io.Serializable;
11 import org.opendaylight.yangtools.concepts.Immutable;
12 import org.opendaylight.yangtools.yang.common.QName;
13
14 public final class RpcRoutingContext implements Immutable, Serializable {
15     private static final long serialVersionUID = -9079324728075883325L;
16
17     private final QName context;
18     private final QName rpc;
19
20
21     private RpcRoutingContext(QName context, QName rpc) {
22         this.context = context;
23         this.rpc = rpc;
24     }
25
26     public static RpcRoutingContext create(QName context, QName rpc) {
27         return new RpcRoutingContext(context, rpc);
28     }
29
30     public QName getContext() {
31         return context;
32     }
33
34     public QName getRpc() {
35         return rpc;
36     }
37
38     @Override
39     public String toString() {
40         return "RpcRoutingContext [context=" + context + ", rpc=" + rpc + "]";
41     }
42
43     @Override
44     public int hashCode() {
45         final int prime = 31;
46         int result = 1;
47         result = prime * result + (context == null ? 0 : context.hashCode());
48         result = prime * result + (rpc == null ? 0 : rpc.hashCode());
49         return result;
50     }
51
52     @Override
53     public boolean equals(Object obj) {
54         if (this == obj) {
55             return true;
56         }
57         if (obj == null) {
58             return false;
59         }
60         if (getClass() != obj.getClass()) {
61             return false;
62         }
63         RpcRoutingContext other = (RpcRoutingContext) obj;
64         if (context == null) {
65             if (other.context != null) {
66                 return false;
67             }
68         } else if (!context.equals(other.context)) {
69             return false;
70         }
71         if (rpc == null) {
72             if (other.rpc != null) {
73                 return false;
74             }
75         } else if (!rpc.equals(other.rpc)) {
76             return false;
77         }
78         return true;
79     }
80 }