ff3bb890924bfa06157a6e8cceb28173d98bb344
[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         this.context = context;
28         this.rpc = rpc;
29     }
30
31     public static final RpcRoutingContext create(QName context, QName rpc) {
32         return new RpcRoutingContext(context, rpc);
33     }
34
35     public QName getContext() {
36         return context;
37     }
38
39     public QName getRpc() {
40         return rpc;
41     }
42
43     @Override
44     public String toString() {
45         return "RpcRoutingContext [context=" + context + ", rpc=" + rpc + "]";
46     }
47
48     @Override
49     public int hashCode() {
50         final int prime = 31;
51         int result = 1;
52         result = prime * result + ((context == null) ? 0 : context.hashCode());
53         result = prime * result + ((rpc == null) ? 0 : rpc.hashCode());
54         return result;
55     }
56
57     @Override
58     public boolean equals(Object obj) {
59         if (this == obj)
60             return true;
61         if (obj == null)
62             return false;
63         if (getClass() != obj.getClass())
64             return false;
65         RpcRoutingContext other = (RpcRoutingContext) obj;
66         if (context == null) {
67             if (other.context != null)
68                 return false;
69         } else if (!context.equals(other.context))
70             return false;
71         if (rpc == null) {
72             if (other.rpc != null)
73                 return false;
74         } else if (!rpc.equals(other.rpc))
75             return false;
76         return true;
77     }
78 }