Deprecate all MD-SAL APIs
[controller.git] / opendaylight / md-sal / sal-binding-api / src / main / java / org / opendaylight / controller / sal / binding / api / rpc / RpcContextIdentifier.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.binding.api.rpc;
9
10 import org.opendaylight.yangtools.concepts.Immutable;
11 import org.opendaylight.yangtools.yang.binding.BaseIdentity;
12 import org.opendaylight.yangtools.yang.binding.RpcService;
13
14 @Deprecated
15 public final class RpcContextIdentifier implements Immutable {
16
17     public final Class<? extends RpcService> rpcService;
18     public final Class<? extends BaseIdentity> routingContext;
19
20     private RpcContextIdentifier(Class<? extends RpcService> rpcService, Class<? extends BaseIdentity> routingContext) {
21         this.rpcService = rpcService;
22         this.routingContext = routingContext;
23     }
24
25     public Class<? extends RpcService> getRpcService() {
26         return rpcService;
27     }
28
29     public Class<? extends BaseIdentity> getRoutingContext() {
30         return routingContext;
31     }
32
33     public static RpcContextIdentifier contextForGlobalRpc(Class<? extends RpcService> serviceType) {
34         return new RpcContextIdentifier(serviceType, null);
35     }
36
37     public static RpcContextIdentifier contextFor(Class<? extends RpcService> serviceType,
38             Class<? extends BaseIdentity> routingContext) {
39         return new RpcContextIdentifier(serviceType, routingContext);
40     }
41
42     @Override
43     public int hashCode() {
44         final int prime = 31;
45         int result = 1;
46         result = prime * result + (routingContext == null ? 0 : routingContext.hashCode());
47         result = prime * result + (rpcService == null ? 0 : rpcService.hashCode());
48         return result;
49     }
50
51     @Override
52     public boolean equals(Object obj) {
53         if (this == obj) {
54             return true;
55         }
56         if (obj == null) {
57             return false;
58         }
59         if (getClass() != obj.getClass()) {
60             return false;
61         }
62         RpcContextIdentifier other = (RpcContextIdentifier) obj;
63         if (routingContext == null) {
64             if (other.routingContext != null) {
65                 return false;
66             }
67         } else if (!routingContext.equals(other.routingContext)) {
68             return false;
69         }
70         if (rpcService == null) {
71             if (other.rpcService != null) {
72                 return false;
73             }
74         } else if (!rpcService.equals(other.rpcService)) {
75             return false;
76         }
77         return true;
78     }
79 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.