jiangrui | a716b65 | 2015-11-25 16:07:37 +0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame^] | 2 | * Copyright 2015-present Open Networking Foundation |
jiangrui | a716b65 | 2015-11-25 16:07:37 +0800 | [diff] [blame] | 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 | */ |
| 16 | package org.onosproject.vtnrsc.event; |
| 17 | |
| 18 | import java.util.Objects; |
| 19 | |
| 20 | import org.onosproject.vtnrsc.FloatingIp; |
| 21 | import org.onosproject.vtnrsc.Router; |
| 22 | import org.onosproject.vtnrsc.RouterInterface; |
Mahesh Poojary S | 427c8ca | 2015-11-29 13:06:31 +0530 | [diff] [blame] | 23 | import org.onosproject.vtnrsc.PortPair; |
| 24 | import org.onosproject.vtnrsc.PortPairGroup; |
| 25 | import org.onosproject.vtnrsc.FlowClassifier; |
| 26 | import org.onosproject.vtnrsc.PortChain; |
Phaneendra Manda | b212bc9 | 2016-07-08 16:50:11 +0530 | [diff] [blame] | 27 | import org.onosproject.vtnrsc.VirtualPort; |
jiangrui | a716b65 | 2015-11-25 16:07:37 +0800 | [diff] [blame] | 28 | |
| 29 | import static com.google.common.base.MoreObjects.toStringHelper; |
| 30 | import static com.google.common.base.Preconditions.checkNotNull; |
| 31 | |
| 32 | /** |
| 33 | * Representation of a VtnRsc event feedback. |
| 34 | */ |
| 35 | public class VtnRscEventFeedback { |
| 36 | private final FloatingIp floaingtIp; |
| 37 | private final Router router; |
| 38 | private final RouterInterface routerInterface; |
Mahesh Poojary S | 427c8ca | 2015-11-29 13:06:31 +0530 | [diff] [blame] | 39 | private final PortPair portPair; |
| 40 | private final PortPairGroup portPairGroup; |
| 41 | private final FlowClassifier flowClassifier; |
| 42 | private final PortChain portChain; |
Phaneendra Manda | b212bc9 | 2016-07-08 16:50:11 +0530 | [diff] [blame] | 43 | private final VirtualPort virtualPort; |
jiangrui | a716b65 | 2015-11-25 16:07:37 +0800 | [diff] [blame] | 44 | |
| 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 S | 427c8ca | 2015-11-29 13:06:31 +0530 | [diff] [blame] | 54 | this.portPair = null; |
| 55 | this.portPairGroup = null; |
| 56 | this.flowClassifier = null; |
| 57 | this.portChain = null; |
Phaneendra Manda | b212bc9 | 2016-07-08 16:50:11 +0530 | [diff] [blame] | 58 | this.virtualPort = null; |
jiangrui | a716b65 | 2015-11-25 16:07:37 +0800 | [diff] [blame] | 59 | } |
| 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 S | 427c8ca | 2015-11-29 13:06:31 +0530 | [diff] [blame] | 70 | this.portPair = null; |
| 71 | this.portPairGroup = null; |
| 72 | this.flowClassifier = null; |
| 73 | this.portChain = null; |
Phaneendra Manda | b212bc9 | 2016-07-08 16:50:11 +0530 | [diff] [blame] | 74 | this.virtualPort = null; |
jiangrui | a716b65 | 2015-11-25 16:07:37 +0800 | [diff] [blame] | 75 | } |
| 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 S | 427c8ca | 2015-11-29 13:06:31 +0530 | [diff] [blame] | 87 | this.portPair = null; |
| 88 | this.portPairGroup = null; |
| 89 | this.flowClassifier = null; |
| 90 | this.portChain = null; |
Phaneendra Manda | b212bc9 | 2016-07-08 16:50:11 +0530 | [diff] [blame] | 91 | this.virtualPort = null; |
Mahesh Poojary S | 427c8ca | 2015-11-29 13:06:31 +0530 | [diff] [blame] | 92 | } |
| 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 Manda | b212bc9 | 2016-07-08 16:50:11 +0530 | [diff] [blame] | 108 | this.virtualPort = null; |
Mahesh Poojary S | 427c8ca | 2015-11-29 13:06:31 +0530 | [diff] [blame] | 109 | } |
| 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 Manda | b212bc9 | 2016-07-08 16:50:11 +0530 | [diff] [blame] | 122 | "Port-Pair-Group cannot be null"); |
Mahesh Poojary S | 427c8ca | 2015-11-29 13:06:31 +0530 | [diff] [blame] | 123 | this.flowClassifier = null; |
| 124 | this.portChain = null; |
Phaneendra Manda | b212bc9 | 2016-07-08 16:50:11 +0530 | [diff] [blame] | 125 | this.virtualPort = null; |
Mahesh Poojary S | 427c8ca | 2015-11-29 13:06:31 +0530 | [diff] [blame] | 126 | } |
| 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 Manda | b212bc9 | 2016-07-08 16:50:11 +0530 | [diff] [blame] | 140 | "Flow-Classifier cannot be null"); |
Mahesh Poojary S | 427c8ca | 2015-11-29 13:06:31 +0530 | [diff] [blame] | 141 | this.portChain = null; |
Phaneendra Manda | b212bc9 | 2016-07-08 16:50:11 +0530 | [diff] [blame] | 142 | this.virtualPort = null; |
Mahesh Poojary S | 427c8ca | 2015-11-29 13:06:31 +0530 | [diff] [blame] | 143 | } |
| 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 Manda | b212bc9 | 2016-07-08 16:50:11 +0530 | [diff] [blame] | 158 | "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"); |
jiangrui | a716b65 | 2015-11-25 16:07:37 +0800 | [diff] [blame] | 177 | } |
| 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 S | 427c8ca | 2015-11-29 13:06:31 +0530 | [diff] [blame] | 206 | /** |
| 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 Manda | b212bc9 | 2016-07-08 16:50:11 +0530 | [diff] [blame] | 242 | /** |
| 243 | * Returns Virtual-Port. |
| 244 | * |
| 245 | * @return virtualPort the Virtual-Port |
| 246 | */ |
| 247 | public VirtualPort virtualPort() { |
| 248 | return virtualPort; |
| 249 | } |
| 250 | |
jiangrui | a716b65 | 2015-11-25 16:07:37 +0800 | [diff] [blame] | 251 | @Override |
| 252 | public int hashCode() { |
Mahesh Poojary S | 427c8ca | 2015-11-29 13:06:31 +0530 | [diff] [blame] | 253 | return Objects.hash(floaingtIp, router, routerInterface, portPair, |
Phaneendra Manda | b212bc9 | 2016-07-08 16:50:11 +0530 | [diff] [blame] | 254 | portPairGroup, flowClassifier, portChain, virtualPort); |
jiangrui | a716b65 | 2015-11-25 16:07:37 +0800 | [diff] [blame] | 255 | } |
| 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 S | 427c8ca | 2015-11-29 13:06:31 +0530 | [diff] [blame] | 266 | && 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 Manda | b212bc9 | 2016-07-08 16:50:11 +0530 | [diff] [blame] | 270 | && Objects.equals(this.portChain, that.portChain) |
| 271 | && Objects.equals(this.virtualPort, that.virtualPort); |
jiangrui | a716b65 | 2015-11-25 16:07:37 +0800 | [diff] [blame] | 272 | } |
| 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 S | 427c8ca | 2015-11-29 13:06:31 +0530 | [diff] [blame] | 282 | .add("portPair", portPair) |
| 283 | .add("portPairGroup", portPairGroup) |
| 284 | .add("flowClassifier", flowClassifier) |
| 285 | .add("portChain", portChain) |
Phaneendra Manda | b212bc9 | 2016-07-08 16:50:11 +0530 | [diff] [blame] | 286 | .add("virtualPort", virtualPort) |
jiangrui | a716b65 | 2015-11-25 16:07:37 +0800 | [diff] [blame] | 287 | .toString(); |
| 288 | } |
| 289 | } |