Bump cds-access-api ABIVersion
[controller.git] / opendaylight / md-sal / sal-connector-api / src / main / java / org / opendaylight / controller / sal / connector / api / BindingAwareRpcRouter.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.connector.api;
9
10 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
11 import java.util.concurrent.Future;
12 import org.opendaylight.yangtools.concepts.Immutable;
13
14 public interface BindingAwareRpcRouter extends RpcRouter<String, String, String, byte[]> {
15
16     @Override
17     Future<org.opendaylight.controller.sal.connector.api.RpcRouter.RpcReply<byte[]>> sendRpc(
18             RpcRequest<String, String, String, byte[]> input);
19
20     @SuppressFBWarnings("EI_EXPOSE_REP2")
21     class BindingAwareRequest implements RpcRequest<String, String, String, byte[]>, Immutable {
22
23         private final BindingAwareRouteIdentifier routingInformation;
24         private final byte[] payload;
25
26         public BindingAwareRequest(BindingAwareRouteIdentifier routingInformation, byte[] payload) {
27             this.routingInformation = routingInformation;
28             this.payload = payload;
29         }
30
31         @Override
32         public BindingAwareRouteIdentifier getRoutingInformation() {
33             return this.routingInformation;
34         }
35
36         @Override
37         @SuppressFBWarnings("EI_EXPOSE_REP")
38         public byte[] getPayload() {
39             return payload;
40         }
41     }
42
43     class BindingAwareRouteIdentifier implements RouteIdentifier<String, String, String>, Immutable {
44
45         private final String type;
46         private final String route;
47         private final String content;
48
49         public BindingAwareRouteIdentifier(String type, String route, String content) {
50             this.type = type;
51             this.route = route;
52             this.content = content;
53         }
54
55         /**
56          * Java class name of Rpc Context.
57          */
58         @Override
59         public String getContext() {
60             return this.content;
61         }
62
63         /**
64          * String representation of route e.g. node-id
65          *
66          */
67         @Override
68         public String getRoute() {
69             return this.route;
70         }
71
72         /**
73          * Java class name of Rpc Type e.g org.opendaylight.AddFlowInput.
74          */
75         @Override
76         public String getType() {
77             return this.type;
78         }
79
80         @Override
81         public int hashCode() {
82             final int prime = 31;
83             int result = 1;
84             result = prime * result + (content == null ? 0 : content.hashCode());
85             result = prime * result + (route == null ? 0 : route.hashCode());
86             result = prime * result + (type == null ? 0 : type.hashCode());
87             return result;
88         }
89
90         @Override
91         public boolean equals(Object obj) {
92             if (this == obj) {
93                 return true;
94             }
95             if (obj == null) {
96                 return false;
97             }
98             if (getClass() != obj.getClass()) {
99                 return false;
100             }
101             BindingAwareRouteIdentifier other = (BindingAwareRouteIdentifier) obj;
102             if (content == null) {
103                 if (other.content != null) {
104                     return false;
105                 }
106             } else if (!content.equals(other.content)) {
107                 return false;
108             }
109             if (route == null) {
110                 if (other.route != null) {
111                     return false;
112                 }
113             } else if (!route.equals(other.route)) {
114                 return false;
115             }
116             if (type == null) {
117                 if (other.type != null) {
118                     return false;
119                 }
120             } else if (!type.equals(other.type)) {
121                 return false;
122             }
123             return true;
124         }
125     }
126 }