Merge "Fix for bug #236 and bug #240 Have made changes in opendaylight-table-types...
[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     public 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             super();
27             this.routingInformation = routingInformation;
28             this.payload = payload;
29         }
30
31         public BindingAwareRouteIdentifier getRoutingInformation() {
32             return this.routingInformation;
33         }
34
35         @Override
36         public byte[] getPayload() {
37             return payload;
38         }
39     }
40
41     class BindingAwareRouteIdentifier implements RouteIdentifier<String, String, String>, Immutable {
42
43         private final String type;
44         private final String route;
45         private final String content;
46
47         public BindingAwareRouteIdentifier(String type, String route, String content) {
48             super();
49             this.type = type;
50             this.route = route;
51             this.content = content;
52         }
53
54         /**
55          * Java class name of Rpc Context
56          * 
57          * 
58          */
59         @Override
60         public String getContext() {
61             return this.content;
62         }
63
64         /**
65          * String representation of route e.g. node-id
66          * 
67          */
68         @Override
69         public String getRoute() {
70             return this.route;
71         }
72
73         /**
74          * Java class name of Rpc Type e.g org.opendaylight.AddFlowInput
75          * 
76          */
77         @Override
78         public String getType() {
79             return this.type;
80         }
81
82         @Override
83         public int hashCode() {
84             final int prime = 31;
85             int result = 1;
86             result = prime * result + ((content == null) ? 0 : content.hashCode());
87             result = prime * result + ((route == null) ? 0 : route.hashCode());
88             result = prime * result + ((type == null) ? 0 : type.hashCode());
89             return result;
90         }
91
92         @Override
93         public boolean equals(Object obj) {
94             if (this == obj)
95                 return true;
96             if (obj == null)
97                 return false;
98             if (getClass() != obj.getClass())
99                 return false;
100             BindingAwareRouteIdentifier other = (BindingAwareRouteIdentifier) obj;
101             if (content == null) {
102                 if (other.content != null)
103                     return false;
104             } else if (!content.equals(other.content))
105                 return false;
106             if (route == null) {
107                 if (other.route != null)
108                     return false;
109             } else if (!route.equals(other.route))
110                 return false;
111             if (type == null) {
112                 if (other.type != null)
113                     return false;
114             } else if (!type.equals(other.type))
115                 return false;
116             return true;
117         }
118
119     }
120
121 }