blob: 1e3f8491c25dddfe89522384a3a1350f8feb3e0d [file] [log] [blame]
jiangruia716b652015-11-25 16:07:37 +08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
jiangruia716b652015-11-25 16:07:37 +08003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.vtnrsc.event;
17
18import java.util.Objects;
19
20import org.onosproject.vtnrsc.FloatingIp;
21import org.onosproject.vtnrsc.Router;
22import org.onosproject.vtnrsc.RouterInterface;
Mahesh Poojary S427c8ca2015-11-29 13:06:31 +053023import org.onosproject.vtnrsc.PortPair;
24import org.onosproject.vtnrsc.PortPairGroup;
25import org.onosproject.vtnrsc.FlowClassifier;
26import org.onosproject.vtnrsc.PortChain;
Phaneendra Mandab212bc92016-07-08 16:50:11 +053027import org.onosproject.vtnrsc.VirtualPort;
jiangruia716b652015-11-25 16:07:37 +080028
29import static com.google.common.base.MoreObjects.toStringHelper;
30import static com.google.common.base.Preconditions.checkNotNull;
31
32/**
33 * Representation of a VtnRsc event feedback.
34 */
35public class VtnRscEventFeedback {
36 private final FloatingIp floaingtIp;
37 private final Router router;
38 private final RouterInterface routerInterface;
Mahesh Poojary S427c8ca2015-11-29 13:06:31 +053039 private final PortPair portPair;
40 private final PortPairGroup portPairGroup;
41 private final FlowClassifier flowClassifier;
42 private final PortChain portChain;
Phaneendra Mandab212bc92016-07-08 16:50:11 +053043 private final VirtualPort virtualPort;
jiangruia716b652015-11-25 16:07:37 +080044
45 /**
46 * Creates VtnRscEventFeedback object.
47 *
48 * @param floatingIp the floating Ip
49 */
50 public VtnRscEventFeedback(FloatingIp floatingIp) {
51 this.floaingtIp = checkNotNull(floatingIp, "floaintIp cannot be null");
52 this.router = null;
53 this.routerInterface = null;
Mahesh Poojary S427c8ca2015-11-29 13:06:31 +053054 this.portPair = null;
55 this.portPairGroup = null;
56 this.flowClassifier = null;
57 this.portChain = null;
Phaneendra Mandab212bc92016-07-08 16:50:11 +053058 this.virtualPort = null;
jiangruia716b652015-11-25 16:07:37 +080059 }
60
61 /**
62 * Creates VtnRscEventFeedback object.
63 *
64 * @param router the router
65 */
66 public VtnRscEventFeedback(Router router) {
67 this.floaingtIp = null;
68 this.router = checkNotNull(router, "router cannot be null");
69 this.routerInterface = null;
Mahesh Poojary S427c8ca2015-11-29 13:06:31 +053070 this.portPair = null;
71 this.portPairGroup = null;
72 this.flowClassifier = null;
73 this.portChain = null;
Phaneendra Mandab212bc92016-07-08 16:50:11 +053074 this.virtualPort = null;
jiangruia716b652015-11-25 16:07:37 +080075 }
76
77 /**
78 * Creates VtnRscEventFeedback object.
79 *
80 * @param routerInterface the router interface
81 */
82 public VtnRscEventFeedback(RouterInterface routerInterface) {
83 this.floaingtIp = null;
84 this.router = null;
85 this.routerInterface = checkNotNull(routerInterface,
86 "routerInterface cannot be null");
Mahesh Poojary S427c8ca2015-11-29 13:06:31 +053087 this.portPair = null;
88 this.portPairGroup = null;
89 this.flowClassifier = null;
90 this.portChain = null;
Phaneendra Mandab212bc92016-07-08 16:50:11 +053091 this.virtualPort = null;
Mahesh Poojary S427c8ca2015-11-29 13:06:31 +053092 }
93
94 /**
95 * Creates VtnRscEventFeedback object.
96 *
97 * @param portPair the Port-Pair
98 */
99 public VtnRscEventFeedback(PortPair portPair) {
100 this.floaingtIp = null;
101 this.router = null;
102 this.routerInterface = null;
103 this.portPair = checkNotNull(portPair,
104 "Port-Pair cannot be null");
105 this.portPairGroup = null;
106 this.flowClassifier = null;
107 this.portChain = null;
Phaneendra Mandab212bc92016-07-08 16:50:11 +0530108 this.virtualPort = null;
Mahesh Poojary S427c8ca2015-11-29 13:06:31 +0530109 }
110
111 /**
112 * Creates VtnRscEventFeedback object.
113 *
114 * @param portPairGroup the Port-Pair-Group
115 */
116 public VtnRscEventFeedback(PortPairGroup portPairGroup) {
117 this.floaingtIp = null;
118 this.router = null;
119 this.routerInterface = null;
120 this.portPair = null;
121 this.portPairGroup = checkNotNull(portPairGroup,
Phaneendra Mandab212bc92016-07-08 16:50:11 +0530122 "Port-Pair-Group cannot be null");
Mahesh Poojary S427c8ca2015-11-29 13:06:31 +0530123 this.flowClassifier = null;
124 this.portChain = null;
Phaneendra Mandab212bc92016-07-08 16:50:11 +0530125 this.virtualPort = null;
Mahesh Poojary S427c8ca2015-11-29 13:06:31 +0530126 }
127
128 /**
129 * Creates VtnRscEventFeedback object.
130 *
131 * @param flowClassifier the Flow-Classifier
132 */
133 public VtnRscEventFeedback(FlowClassifier flowClassifier) {
134 this.floaingtIp = null;
135 this.router = null;
136 this.routerInterface = null;
137 this.portPair = null;
138 this.portPairGroup = null;
139 this.flowClassifier = checkNotNull(flowClassifier,
Phaneendra Mandab212bc92016-07-08 16:50:11 +0530140 "Flow-Classifier cannot be null");
Mahesh Poojary S427c8ca2015-11-29 13:06:31 +0530141 this.portChain = null;
Phaneendra Mandab212bc92016-07-08 16:50:11 +0530142 this.virtualPort = null;
Mahesh Poojary S427c8ca2015-11-29 13:06:31 +0530143 }
144
145 /**
146 * Creates VtnRscEventFeedback object.
147 *
148 * @param portChain the Port-Chain
149 */
150 public VtnRscEventFeedback(PortChain portChain) {
151 this.floaingtIp = null;
152 this.router = null;
153 this.routerInterface = null;
154 this.portPair = null;
155 this.portPairGroup = null;
156 this.flowClassifier = null;
157 this.portChain = checkNotNull(portChain,
Phaneendra Mandab212bc92016-07-08 16:50:11 +0530158 "Port-Chain cannot be null");
159 this.virtualPort = null;
160 }
161
162 /**
163 * Creates VtnRscEventFeedback object.
164 *
165 * @param virtualPort the Virtual-Port
166 */
167 public VtnRscEventFeedback(VirtualPort virtualPort) {
168 this.floaingtIp = null;
169 this.router = null;
170 this.routerInterface = null;
171 this.portPair = null;
172 this.portPairGroup = null;
173 this.flowClassifier = null;
174 this.portChain = null;
175 this.virtualPort = checkNotNull(virtualPort,
176 "Virtual-port cannot be null");
jiangruia716b652015-11-25 16:07:37 +0800177 }
178
179 /**
180 * Returns floating IP.
181 *
182 * @return floaingtIp the floating IP
183 */
184 public FloatingIp floatingIp() {
185 return floaingtIp;
186 }
187
188 /**
189 * Returns router.
190 *
191 * @return router the router
192 */
193 public Router router() {
194 return router;
195 }
196
197 /**
198 * Returns router interface.
199 *
200 * @return routerInterface the router interface
201 */
202 public RouterInterface routerInterface() {
203 return routerInterface;
204 }
205
Mahesh Poojary S427c8ca2015-11-29 13:06:31 +0530206 /**
207 * Returns Port-Pair.
208 *
209 * @return portPair the Port-Pair
210 */
211 public PortPair portPair() {
212 return portPair;
213 }
214
215 /**
216 * Returns Port-Pair-Group.
217 *
218 * @return portPairGroup the Port-Pair-Group
219 */
220 public PortPairGroup portPairGroup() {
221 return portPairGroup;
222 }
223
224 /**
225 * Returns Flow-Classifier.
226 *
227 * @return flowClassifier the Flow-Classifier
228 */
229 public FlowClassifier flowClassifier() {
230 return flowClassifier;
231 }
232
233 /**
234 * Returns Port-Chain.
235 *
236 * @return portChain the Port-Chain
237 */
238 public PortChain portChain() {
239 return portChain;
240 }
241
Phaneendra Mandab212bc92016-07-08 16:50:11 +0530242 /**
243 * Returns Virtual-Port.
244 *
245 * @return virtualPort the Virtual-Port
246 */
247 public VirtualPort virtualPort() {
248 return virtualPort;
249 }
250
jiangruia716b652015-11-25 16:07:37 +0800251 @Override
252 public int hashCode() {
Mahesh Poojary S427c8ca2015-11-29 13:06:31 +0530253 return Objects.hash(floaingtIp, router, routerInterface, portPair,
Phaneendra Mandab212bc92016-07-08 16:50:11 +0530254 portPairGroup, flowClassifier, portChain, virtualPort);
jiangruia716b652015-11-25 16:07:37 +0800255 }
256
257 @Override
258 public boolean equals(Object obj) {
259 if (this == obj) {
260 return true;
261 }
262 if (obj instanceof VtnRscEventFeedback) {
263 final VtnRscEventFeedback that = (VtnRscEventFeedback) obj;
264 return Objects.equals(this.floaingtIp, that.floaingtIp)
265 && Objects.equals(this.router, that.router)
Mahesh Poojary S427c8ca2015-11-29 13:06:31 +0530266 && Objects.equals(this.routerInterface, that.routerInterface)
267 && Objects.equals(this.portPair, that.portPair)
268 && Objects.equals(this.portPairGroup, that.portPairGroup)
269 && Objects.equals(this.flowClassifier, that.flowClassifier)
Phaneendra Mandab212bc92016-07-08 16:50:11 +0530270 && Objects.equals(this.portChain, that.portChain)
271 && Objects.equals(this.virtualPort, that.virtualPort);
jiangruia716b652015-11-25 16:07:37 +0800272 }
273 return false;
274 }
275
276 @Override
277 public String toString() {
278 return toStringHelper(this)
279 .add("router", router)
280 .add("floaingtIp", floaingtIp)
281 .add("routerInterface", routerInterface)
Mahesh Poojary S427c8ca2015-11-29 13:06:31 +0530282 .add("portPair", portPair)
283 .add("portPairGroup", portPairGroup)
284 .add("flowClassifier", flowClassifier)
285 .add("portChain", portChain)
Phaneendra Mandab212bc92016-07-08 16:50:11 +0530286 .add("virtualPort", virtualPort)
jiangruia716b652015-11-25 16:07:37 +0800287 .toString();
288 }
289}