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