17221bc0af4fe1894022d6db05af3400d8c0aeb9
[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 java.util.concurrent.Future;
11
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     class BindingAwareRequest implements RpcRequest<String, String, String, byte[]>, Immutable {
21
22         private final BindingAwareRouteIdentifier routingInformation;
23         private final byte[] payload;
24
25         public BindingAwareRequest(BindingAwareRouteIdentifier routingInformation, byte[] payload) {
26             this.routingInformation = routingInformation;
27             this.payload = payload;
28         }
29
30         public BindingAwareRouteIdentifier getRoutingInformation() {
31             return this.routingInformation;
32         }
33
34         @Override
35         public byte[] getPayload() {
36             return payload;
37         }
38     }
39
40     class BindingAwareRouteIdentifier implements RouteIdentifier<String, String, String>, Immutable {
41
42         private final String type;
43         private final String route;
44         private final String content;
45
46         public BindingAwareRouteIdentifier(String type, String route, String content) {
47             this.type = type;
48             this.route = route;
49             this.content = content;
50         }
51
52         /**
53          * Java class name of Rpc Context
54          *
55          *
56          */
57         @Override
58         public String getContext() {
59             return this.content;
60         }
61
62         /**
63          * String representation of route e.g. node-id
64          *
65          */
66         @Override
67         public String getRoute() {
68             return this.route;
69         }
70
71         /**
72          * Java class name of Rpc Type e.g org.opendaylight.AddFlowInput
73          *
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             if (obj == null)
95                 return false;
96             if (getClass() != obj.getClass())
97                 return false;
98             BindingAwareRouteIdentifier other = (BindingAwareRouteIdentifier) obj;
99             if (content == null) {
100                 if (other.content != null)
101                     return false;
102             } else if (!content.equals(other.content))
103                 return false;
104             if (route == null) {
105                 if (other.route != null)
106                     return false;
107             } else if (!route.equals(other.route))
108                 return false;
109             if (type == null) {
110                 if (other.type != null)
111                     return false;
112             } else if (!type.equals(other.type))
113                 return false;
114             return true;
115         }
116
117     }
118
119 }