2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.sal.binding.api.rpc;
10 import org.opendaylight.yangtools.concepts.Immutable;
11 import org.opendaylight.yangtools.yang.binding.BaseIdentity;
12 import org.opendaylight.yangtools.yang.binding.RpcService;
15 public final class RpcContextIdentifier implements Immutable {
17 public final Class<? extends RpcService> rpcService;
18 public final Class<? extends BaseIdentity> routingContext;
20 private RpcContextIdentifier(Class<? extends RpcService> rpcService, Class<? extends BaseIdentity> routingContext) {
21 this.rpcService = rpcService;
22 this.routingContext = routingContext;
25 public Class<? extends RpcService> getRpcService() {
29 public Class<? extends BaseIdentity> getRoutingContext() {
30 return routingContext;
33 public static RpcContextIdentifier contextForGlobalRpc(Class<? extends RpcService> serviceType) {
34 return new RpcContextIdentifier(serviceType, null);
37 public static RpcContextIdentifier contextFor(Class<? extends RpcService> serviceType,
38 Class<? extends BaseIdentity> routingContext) {
39 return new RpcContextIdentifier(serviceType, routingContext);
43 public int hashCode() {
46 result = prime * result + (routingContext == null ? 0 : routingContext.hashCode());
47 result = prime * result + (rpcService == null ? 0 : rpcService.hashCode());
52 public boolean equals(Object obj) {
59 if (getClass() != obj.getClass()) {
62 RpcContextIdentifier other = (RpcContextIdentifier) obj;
63 if (routingContext == null) {
64 if (other.routingContext != null) {
67 } else if (!routingContext.equals(other.routingContext)) {
70 if (rpcService == null) {
71 if (other.rpcService != null) {
74 } else if (!rpcService.equals(other.rpcService)) {