blob: 112c641152846d21d2507a34ca7bdc66f3028b71 [file] [log] [blame]
jiangruia716b652015-11-25 16:07:37 +08001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
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;
jiangruia716b652015-11-25 16:07:37 +080027
28import static com.google.common.base.MoreObjects.toStringHelper;
29import static com.google.common.base.Preconditions.checkNotNull;
30
31/**
32 * Representation of a VtnRsc event feedback.
33 */
34public class VtnRscEventFeedback {
35 private final FloatingIp floaingtIp;
36 private final Router router;
37 private final RouterInterface routerInterface;
Mahesh Poojary S427c8ca2015-11-29 13:06:31 +053038 private final PortPair portPair;
39 private final PortPairGroup portPairGroup;
40 private final FlowClassifier flowClassifier;
41 private final PortChain portChain;
jiangruia716b652015-11-25 16:07:37 +080042
43 /**
44 * Creates VtnRscEventFeedback object.
45 *
46 * @param floatingIp the floating Ip
47 */
48 public VtnRscEventFeedback(FloatingIp floatingIp) {
49 this.floaingtIp = checkNotNull(floatingIp, "floaintIp cannot be null");
50 this.router = null;
51 this.routerInterface = null;
Mahesh Poojary S427c8ca2015-11-29 13:06:31 +053052 this.portPair = null;
53 this.portPairGroup = null;
54 this.flowClassifier = null;
55 this.portChain = null;
jiangruia716b652015-11-25 16:07:37 +080056 }
57
58 /**
59 * Creates VtnRscEventFeedback object.
60 *
61 * @param router the router
62 */
63 public VtnRscEventFeedback(Router router) {
64 this.floaingtIp = null;
65 this.router = checkNotNull(router, "router cannot be null");
66 this.routerInterface = null;
Mahesh Poojary S427c8ca2015-11-29 13:06:31 +053067 this.portPair = null;
68 this.portPairGroup = null;
69 this.flowClassifier = null;
70 this.portChain = null;
jiangruia716b652015-11-25 16:07:37 +080071 }
72
73 /**
74 * Creates VtnRscEventFeedback object.
75 *
76 * @param routerInterface the router interface
77 */
78 public VtnRscEventFeedback(RouterInterface routerInterface) {
79 this.floaingtIp = null;
80 this.router = null;
81 this.routerInterface = checkNotNull(routerInterface,
82 "routerInterface cannot be null");
Mahesh Poojary S427c8ca2015-11-29 13:06:31 +053083 this.portPair = null;
84 this.portPairGroup = null;
85 this.flowClassifier = null;
86 this.portChain = null;
87 }
88
89 /**
90 * Creates VtnRscEventFeedback object.
91 *
92 * @param portPair the Port-Pair
93 */
94 public VtnRscEventFeedback(PortPair portPair) {
95 this.floaingtIp = null;
96 this.router = null;
97 this.routerInterface = null;
98 this.portPair = checkNotNull(portPair,
99 "Port-Pair cannot be null");
100 this.portPairGroup = null;
101 this.flowClassifier = null;
102 this.portChain = null;
103 }
104
105 /**
106 * Creates VtnRscEventFeedback object.
107 *
108 * @param portPairGroup the Port-Pair-Group
109 */
110 public VtnRscEventFeedback(PortPairGroup portPairGroup) {
111 this.floaingtIp = null;
112 this.router = null;
113 this.routerInterface = null;
114 this.portPair = null;
115 this.portPairGroup = checkNotNull(portPairGroup,
116 "Port-Pair-Group cannot be null");
117 this.flowClassifier = null;
118 this.portChain = null;
119 }
120
121 /**
122 * Creates VtnRscEventFeedback object.
123 *
124 * @param flowClassifier the Flow-Classifier
125 */
126 public VtnRscEventFeedback(FlowClassifier flowClassifier) {
127 this.floaingtIp = null;
128 this.router = null;
129 this.routerInterface = null;
130 this.portPair = null;
131 this.portPairGroup = null;
132 this.flowClassifier = checkNotNull(flowClassifier,
133 "Flow-Classifier cannot be null");
134 this.portChain = null;
135 }
136
137 /**
138 * Creates VtnRscEventFeedback object.
139 *
140 * @param portChain the Port-Chain
141 */
142 public VtnRscEventFeedback(PortChain portChain) {
143 this.floaingtIp = null;
144 this.router = null;
145 this.routerInterface = null;
146 this.portPair = null;
147 this.portPairGroup = null;
148 this.flowClassifier = null;
149 this.portChain = checkNotNull(portChain,
150 "Port-Chain cannot be null");
jiangruia716b652015-11-25 16:07:37 +0800151 }
152
153 /**
154 * Returns floating IP.
155 *
156 * @return floaingtIp the floating IP
157 */
158 public FloatingIp floatingIp() {
159 return floaingtIp;
160 }
161
162 /**
163 * Returns router.
164 *
165 * @return router the router
166 */
167 public Router router() {
168 return router;
169 }
170
171 /**
172 * Returns router interface.
173 *
174 * @return routerInterface the router interface
175 */
176 public RouterInterface routerInterface() {
177 return routerInterface;
178 }
179
Mahesh Poojary S427c8ca2015-11-29 13:06:31 +0530180 /**
181 * Returns Port-Pair.
182 *
183 * @return portPair the Port-Pair
184 */
185 public PortPair portPair() {
186 return portPair;
187 }
188
189 /**
190 * Returns Port-Pair-Group.
191 *
192 * @return portPairGroup the Port-Pair-Group
193 */
194 public PortPairGroup portPairGroup() {
195 return portPairGroup;
196 }
197
198 /**
199 * Returns Flow-Classifier.
200 *
201 * @return flowClassifier the Flow-Classifier
202 */
203 public FlowClassifier flowClassifier() {
204 return flowClassifier;
205 }
206
207 /**
208 * Returns Port-Chain.
209 *
210 * @return portChain the Port-Chain
211 */
212 public PortChain portChain() {
213 return portChain;
214 }
215
jiangruia716b652015-11-25 16:07:37 +0800216 @Override
217 public int hashCode() {
Mahesh Poojary S427c8ca2015-11-29 13:06:31 +0530218 return Objects.hash(floaingtIp, router, routerInterface, portPair,
219 portPairGroup, flowClassifier, portChain);
jiangruia716b652015-11-25 16:07:37 +0800220 }
221
222 @Override
223 public boolean equals(Object obj) {
224 if (this == obj) {
225 return true;
226 }
227 if (obj instanceof VtnRscEventFeedback) {
228 final VtnRscEventFeedback that = (VtnRscEventFeedback) obj;
229 return Objects.equals(this.floaingtIp, that.floaingtIp)
230 && Objects.equals(this.router, that.router)
Mahesh Poojary S427c8ca2015-11-29 13:06:31 +0530231 && Objects.equals(this.routerInterface, that.routerInterface)
232 && Objects.equals(this.portPair, that.portPair)
233 && Objects.equals(this.portPairGroup, that.portPairGroup)
234 && Objects.equals(this.flowClassifier, that.flowClassifier)
235 && Objects.equals(this.portChain, that.portChain);
jiangruia716b652015-11-25 16:07:37 +0800236 }
237 return false;
238 }
239
240 @Override
241 public String toString() {
242 return toStringHelper(this)
243 .add("router", router)
244 .add("floaingtIp", floaingtIp)
245 .add("routerInterface", routerInterface)
Mahesh Poojary S427c8ca2015-11-29 13:06:31 +0530246 .add("portPair", portPair)
247 .add("portPairGroup", portPairGroup)
248 .add("flowClassifier", flowClassifier)
249 .add("portChain", portChain)
jiangruia716b652015-11-25 16:07:37 +0800250 .toString();
251 }
252}