Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
alshabib | 7410fea | 2014-09-16 13:48:39 -0700 | [diff] [blame] | 19 | package org.onlab.onos.net.flow.criteria; |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 20 | |
alshabib | 99b8fdc | 2014-09-25 14:30:22 -0700 | [diff] [blame] | 21 | import static com.google.common.base.MoreObjects.toStringHelper; |
| 22 | |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 23 | import java.util.Objects; |
| 24 | |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 25 | import org.onlab.onos.net.PortNumber; |
| 26 | import org.onlab.onos.net.flow.criteria.Criterion.Type; |
Ayaka Koshibe | 1d56fe4 | 2014-09-19 16:51:58 -0700 | [diff] [blame] | 27 | import org.onlab.packet.IpPrefix; |
Ayaka Koshibe | a9c199f | 2014-09-16 16:21:40 -0700 | [diff] [blame] | 28 | import org.onlab.packet.MacAddress; |
| 29 | import org.onlab.packet.VlanId; |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 30 | |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 31 | /** |
| 32 | * Factory class to create various traffic selection criteria. |
| 33 | */ |
| 34 | public final class Criteria { |
| 35 | |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 36 | //TODO: incomplete type implementation. Need to implement complete list from Criterion |
| 37 | |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 38 | // Ban construction |
| 39 | private Criteria() { |
| 40 | } |
| 41 | |
| 42 | /** |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 43 | * Creates a match on IN_PORT field using the specified value. |
| 44 | * |
| 45 | * @param port inport value |
| 46 | * @return match criterion |
| 47 | */ |
| 48 | public static Criterion matchInPort(PortNumber port) { |
| 49 | return new PortCriterion(port); |
| 50 | } |
| 51 | |
| 52 | /** |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 53 | * Creates a match on ETH_SRC field using the specified value. This value |
| 54 | * may be a wildcard mask. |
| 55 | * |
tom | c104d28 | 2014-09-19 10:57:55 -0700 | [diff] [blame] | 56 | * @param mac MAC address value or wildcard mask |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 57 | * @return match criterion |
| 58 | */ |
Ayaka Koshibe | a9c199f | 2014-09-16 16:21:40 -0700 | [diff] [blame] | 59 | public static Criterion matchEthSrc(MacAddress mac) { |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 60 | return new EthCriterion(mac, Type.ETH_SRC); |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 61 | } |
| 62 | |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 63 | /** |
| 64 | * Creates a match on ETH_DST field using the specified value. This value |
| 65 | * may be a wildcard mask. |
| 66 | * |
tom | c104d28 | 2014-09-19 10:57:55 -0700 | [diff] [blame] | 67 | * @param mac MAC address value or wildcard mask |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 68 | * @return match criterion |
| 69 | */ |
Ayaka Koshibe | a9c199f | 2014-09-16 16:21:40 -0700 | [diff] [blame] | 70 | public static Criterion matchEthDst(MacAddress mac) { |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 71 | return new EthCriterion(mac, Type.ETH_DST); |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Creates a match on ETH_TYPE field using the specified value. |
| 76 | * |
| 77 | * @param ethType eth type value |
| 78 | * @return match criterion |
| 79 | */ |
| 80 | public static Criterion matchEthType(Short ethType) { |
| 81 | return new EthTypeCriterion(ethType); |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * Creates a match on VLAN ID field using the specified value. |
| 86 | * |
| 87 | * @param vlanId vlan id value |
| 88 | * @return match criterion |
| 89 | */ |
Ayaka Koshibe | a9c199f | 2014-09-16 16:21:40 -0700 | [diff] [blame] | 90 | public static Criterion matchVlanId(VlanId vlanId) { |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 91 | return new VlanIdCriterion(vlanId); |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * Creates a match on VLAN PCP field using the specified value. |
| 96 | * |
| 97 | * @param vlanPcp vlan pcp value |
| 98 | * @return match criterion |
| 99 | */ |
alshabib | b45d196 | 2014-09-18 14:25:45 -0700 | [diff] [blame] | 100 | public static Criterion matchVlanPcp(Byte vlanPcp) { |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 101 | return new VlanPcpCriterion(vlanPcp); |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * Creates a match on IP proto field using the specified value. |
| 106 | * |
| 107 | * @param proto ip protocol value |
| 108 | * @return match criterion |
| 109 | */ |
| 110 | public static Criterion matchIPProtocol(Byte proto) { |
| 111 | return new IPProtocolCriterion(proto); |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * Creates a match on IP src field using the specified value. |
| 116 | * |
| 117 | * @param ip ip src value |
| 118 | * @return match criterion |
| 119 | */ |
Ayaka Koshibe | 1d56fe4 | 2014-09-19 16:51:58 -0700 | [diff] [blame] | 120 | public static Criterion matchIPSrc(IpPrefix ip) { |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 121 | return new IPCriterion(ip, Type.IPV4_SRC); |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Creates a match on IP dst field using the specified value. |
| 126 | * |
| 127 | * @param ip ip src value |
| 128 | * @return match criterion |
| 129 | */ |
Ayaka Koshibe | 1d56fe4 | 2014-09-19 16:51:58 -0700 | [diff] [blame] | 130 | public static Criterion matchIPDst(IpPrefix ip) { |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 131 | return new IPCriterion(ip, Type.IPV4_DST); |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 132 | } |
| 133 | |
Toshio Koide | 9c44c9a | 2014-10-09 11:44:36 -0700 | [diff] [blame] | 134 | /** |
| 135 | * Creates a match on TCP source port field using the specified value. |
| 136 | * |
| 137 | * @param tcpPort |
| 138 | * @return match criterion |
| 139 | */ |
| 140 | public static Criterion matchTcpSrc(Short tcpPort) { |
| 141 | return new TcpPortCriterion(tcpPort, Type.TCP_SRC); |
| 142 | } |
| 143 | |
| 144 | /** |
| 145 | * Creates a match on TCP destination port field using the specified value. |
| 146 | * |
| 147 | * @param tcpPort |
| 148 | * @return match criterion |
| 149 | */ |
| 150 | public static Criterion matchTcpDst(Short tcpPort) { |
| 151 | return new TcpPortCriterion(tcpPort, Type.TCP_DST); |
| 152 | } |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 153 | |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 154 | /* |
| 155 | * Implementations of criteria. |
| 156 | */ |
| 157 | |
| 158 | public static final class PortCriterion implements Criterion { |
| 159 | private final PortNumber port; |
| 160 | |
| 161 | public PortCriterion(PortNumber port) { |
| 162 | this.port = port; |
| 163 | } |
| 164 | |
| 165 | @Override |
| 166 | public Type type() { |
| 167 | return Type.IN_PORT; |
| 168 | } |
| 169 | |
| 170 | public PortNumber port() { |
| 171 | return this.port; |
| 172 | } |
alshabib | 99b8fdc | 2014-09-25 14:30:22 -0700 | [diff] [blame] | 173 | |
| 174 | @Override |
| 175 | public String toString() { |
| 176 | return toStringHelper(type().toString()) |
| 177 | .add("port", port).toString(); |
| 178 | } |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 179 | |
| 180 | @Override |
| 181 | public int hashCode() { |
alshabib | 2020b89 | 2014-10-20 15:47:08 -0700 | [diff] [blame] | 182 | return Objects.hash(port, type()); |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 183 | } |
| 184 | |
| 185 | @Override |
| 186 | public boolean equals(Object obj) { |
| 187 | if (this == obj) { |
| 188 | return true; |
| 189 | } |
| 190 | if (obj instanceof PortCriterion) { |
| 191 | PortCriterion that = (PortCriterion) obj; |
alshabib | 2020b89 | 2014-10-20 15:47:08 -0700 | [diff] [blame] | 192 | return Objects.equals(port, that.port) && |
| 193 | Objects.equals(this.type(), that.type()); |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 194 | |
| 195 | } |
| 196 | return false; |
| 197 | } |
| 198 | |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 199 | } |
| 200 | |
| 201 | |
| 202 | public static final class EthCriterion implements Criterion { |
Ayaka Koshibe | a9c199f | 2014-09-16 16:21:40 -0700 | [diff] [blame] | 203 | private final MacAddress mac; |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 204 | private final Type type; |
| 205 | |
Ayaka Koshibe | a9c199f | 2014-09-16 16:21:40 -0700 | [diff] [blame] | 206 | public EthCriterion(MacAddress mac, Type type) { |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 207 | this.mac = mac; |
| 208 | this.type = type; |
| 209 | } |
| 210 | |
| 211 | @Override |
| 212 | public Type type() { |
| 213 | return this.type; |
| 214 | } |
| 215 | |
Ayaka Koshibe | a9c199f | 2014-09-16 16:21:40 -0700 | [diff] [blame] | 216 | public MacAddress mac() { |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 217 | return this.mac; |
| 218 | } |
alshabib | 99b8fdc | 2014-09-25 14:30:22 -0700 | [diff] [blame] | 219 | |
| 220 | @Override |
| 221 | public String toString() { |
| 222 | return toStringHelper(type().toString()) |
| 223 | .add("mac", mac).toString(); |
| 224 | } |
| 225 | |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 226 | @Override |
| 227 | public int hashCode() { |
| 228 | return Objects.hash(mac, type); |
| 229 | } |
| 230 | |
| 231 | @Override |
| 232 | public boolean equals(Object obj) { |
| 233 | if (this == obj) { |
| 234 | return true; |
| 235 | } |
| 236 | if (obj instanceof EthCriterion) { |
| 237 | EthCriterion that = (EthCriterion) obj; |
| 238 | return Objects.equals(mac, that.mac) && |
| 239 | Objects.equals(type, that.type); |
| 240 | |
| 241 | |
| 242 | } |
| 243 | return false; |
| 244 | } |
| 245 | |
| 246 | |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 247 | } |
| 248 | |
| 249 | public static final class EthTypeCriterion implements Criterion { |
| 250 | |
| 251 | private final Short ethType; |
| 252 | |
| 253 | public EthTypeCriterion(Short ethType) { |
| 254 | this.ethType = ethType; |
| 255 | } |
| 256 | |
| 257 | @Override |
| 258 | public Type type() { |
| 259 | return Type.ETH_TYPE; |
| 260 | } |
| 261 | |
| 262 | public Short ethType() { |
| 263 | return ethType; |
| 264 | } |
| 265 | |
alshabib | 99b8fdc | 2014-09-25 14:30:22 -0700 | [diff] [blame] | 266 | @Override |
| 267 | public String toString() { |
| 268 | return toStringHelper(type().toString()) |
| 269 | .add("ethType", Long.toHexString(ethType)).toString(); |
| 270 | } |
| 271 | |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 272 | @Override |
| 273 | public int hashCode() { |
alshabib | 2020b89 | 2014-10-20 15:47:08 -0700 | [diff] [blame] | 274 | return Objects.hash(ethType, type()); |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 275 | } |
| 276 | |
| 277 | @Override |
| 278 | public boolean equals(Object obj) { |
| 279 | if (this == obj) { |
| 280 | return true; |
| 281 | } |
| 282 | if (obj instanceof EthTypeCriterion) { |
| 283 | EthTypeCriterion that = (EthTypeCriterion) obj; |
alshabib | 2020b89 | 2014-10-20 15:47:08 -0700 | [diff] [blame] | 284 | return Objects.equals(ethType, that.ethType) && |
| 285 | Objects.equals(this.type(), that.type()); |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 286 | |
| 287 | |
| 288 | } |
| 289 | return false; |
| 290 | } |
| 291 | |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 292 | } |
| 293 | |
| 294 | |
| 295 | public static final class IPCriterion implements Criterion { |
| 296 | |
Ayaka Koshibe | 1d56fe4 | 2014-09-19 16:51:58 -0700 | [diff] [blame] | 297 | private final IpPrefix ip; |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 298 | private final Type type; |
| 299 | |
Ayaka Koshibe | 1d56fe4 | 2014-09-19 16:51:58 -0700 | [diff] [blame] | 300 | public IPCriterion(IpPrefix ip, Type type) { |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 301 | this.ip = ip; |
| 302 | this.type = type; |
| 303 | } |
| 304 | |
| 305 | @Override |
| 306 | public Type type() { |
| 307 | return this.type; |
| 308 | } |
| 309 | |
Ayaka Koshibe | 1d56fe4 | 2014-09-19 16:51:58 -0700 | [diff] [blame] | 310 | public IpPrefix ip() { |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 311 | return this.ip; |
| 312 | } |
| 313 | |
alshabib | 99b8fdc | 2014-09-25 14:30:22 -0700 | [diff] [blame] | 314 | @Override |
| 315 | public String toString() { |
| 316 | return toStringHelper(type().toString()) |
| 317 | .add("ip", ip).toString(); |
| 318 | } |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 319 | |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 320 | @Override |
| 321 | public int hashCode() { |
| 322 | return Objects.hash(ip, type); |
| 323 | } |
| 324 | |
| 325 | @Override |
| 326 | public boolean equals(Object obj) { |
| 327 | if (this == obj) { |
| 328 | return true; |
| 329 | } |
| 330 | if (obj instanceof IPCriterion) { |
| 331 | IPCriterion that = (IPCriterion) obj; |
| 332 | return Objects.equals(ip, that.ip) && |
| 333 | Objects.equals(type, that.type); |
| 334 | |
| 335 | |
| 336 | } |
| 337 | return false; |
| 338 | } |
| 339 | |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 340 | } |
| 341 | |
| 342 | |
| 343 | public static final class IPProtocolCriterion implements Criterion { |
| 344 | |
| 345 | private final Byte proto; |
| 346 | |
| 347 | public IPProtocolCriterion(Byte protocol) { |
| 348 | this.proto = protocol; |
| 349 | } |
| 350 | |
| 351 | @Override |
| 352 | public Type type() { |
| 353 | return Type.IP_PROTO; |
| 354 | } |
| 355 | |
| 356 | public Byte protocol() { |
| 357 | return proto; |
| 358 | } |
| 359 | |
alshabib | 99b8fdc | 2014-09-25 14:30:22 -0700 | [diff] [blame] | 360 | @Override |
| 361 | public String toString() { |
| 362 | return toStringHelper(type().toString()) |
| 363 | .add("protocol", Long.toHexString(proto)).toString(); |
| 364 | } |
| 365 | |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 366 | @Override |
| 367 | public int hashCode() { |
alshabib | 2020b89 | 2014-10-20 15:47:08 -0700 | [diff] [blame] | 368 | return Objects.hash(proto, type()); |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 369 | } |
| 370 | |
| 371 | @Override |
| 372 | public boolean equals(Object obj) { |
| 373 | if (this == obj) { |
| 374 | return true; |
| 375 | } |
| 376 | if (obj instanceof IPProtocolCriterion) { |
| 377 | IPProtocolCriterion that = (IPProtocolCriterion) obj; |
| 378 | return Objects.equals(proto, that.proto); |
| 379 | |
| 380 | |
| 381 | } |
| 382 | return false; |
| 383 | } |
| 384 | |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 385 | } |
| 386 | |
| 387 | |
| 388 | public static final class VlanPcpCriterion implements Criterion { |
| 389 | |
| 390 | private final Byte vlanPcp; |
| 391 | |
| 392 | public VlanPcpCriterion(Byte vlanPcp) { |
| 393 | this.vlanPcp = vlanPcp; |
| 394 | } |
| 395 | |
| 396 | @Override |
| 397 | public Type type() { |
| 398 | return Type.VLAN_PCP; |
| 399 | } |
| 400 | |
alshabib | 35edb1a | 2014-09-16 17:44:44 -0700 | [diff] [blame] | 401 | public Byte priority() { |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 402 | return vlanPcp; |
| 403 | } |
| 404 | |
alshabib | 99b8fdc | 2014-09-25 14:30:22 -0700 | [diff] [blame] | 405 | @Override |
| 406 | public String toString() { |
| 407 | return toStringHelper(type().toString()) |
| 408 | .add("pcp", Long.toHexString(vlanPcp)).toString(); |
| 409 | } |
| 410 | |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 411 | @Override |
| 412 | public int hashCode() { |
| 413 | return Objects.hash(vlanPcp); |
| 414 | } |
| 415 | |
| 416 | @Override |
| 417 | public boolean equals(Object obj) { |
| 418 | if (this == obj) { |
| 419 | return true; |
| 420 | } |
| 421 | if (obj instanceof VlanPcpCriterion) { |
| 422 | VlanPcpCriterion that = (VlanPcpCriterion) obj; |
alshabib | 2020b89 | 2014-10-20 15:47:08 -0700 | [diff] [blame] | 423 | return Objects.equals(vlanPcp, that.vlanPcp) && |
| 424 | Objects.equals(this.type(), that.type()); |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 425 | |
| 426 | |
| 427 | } |
| 428 | return false; |
| 429 | } |
| 430 | |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 431 | } |
| 432 | |
| 433 | |
| 434 | public static final class VlanIdCriterion implements Criterion { |
| 435 | |
| 436 | |
Ayaka Koshibe | a9c199f | 2014-09-16 16:21:40 -0700 | [diff] [blame] | 437 | private final VlanId vlanId; |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 438 | |
Ayaka Koshibe | a9c199f | 2014-09-16 16:21:40 -0700 | [diff] [blame] | 439 | public VlanIdCriterion(VlanId vlanId) { |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 440 | this.vlanId = vlanId; |
| 441 | } |
| 442 | |
| 443 | @Override |
| 444 | public Type type() { |
| 445 | return Type.VLAN_VID; |
| 446 | } |
| 447 | |
Ayaka Koshibe | a9c199f | 2014-09-16 16:21:40 -0700 | [diff] [blame] | 448 | public VlanId vlanId() { |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 449 | return vlanId; |
| 450 | } |
| 451 | |
alshabib | 99b8fdc | 2014-09-25 14:30:22 -0700 | [diff] [blame] | 452 | @Override |
| 453 | public String toString() { |
| 454 | return toStringHelper(type().toString()) |
| 455 | .add("id", vlanId).toString(); |
| 456 | } |
| 457 | |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 458 | @Override |
| 459 | public int hashCode() { |
alshabib | 2020b89 | 2014-10-20 15:47:08 -0700 | [diff] [blame] | 460 | return Objects.hash(vlanId, type()); |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 461 | } |
| 462 | |
| 463 | @Override |
| 464 | public boolean equals(Object obj) { |
| 465 | if (this == obj) { |
| 466 | return true; |
| 467 | } |
| 468 | if (obj instanceof VlanIdCriterion) { |
| 469 | VlanIdCriterion that = (VlanIdCriterion) obj; |
alshabib | 2020b89 | 2014-10-20 15:47:08 -0700 | [diff] [blame] | 470 | return Objects.equals(vlanId, that.vlanId) && |
| 471 | Objects.equals(this.type(), that.type()); |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 472 | |
| 473 | |
| 474 | } |
| 475 | return false; |
| 476 | } |
| 477 | |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 478 | } |
| 479 | |
| 480 | |
Toshio Koide | 9c44c9a | 2014-10-09 11:44:36 -0700 | [diff] [blame] | 481 | public static final class TcpPortCriterion implements Criterion { |
| 482 | |
| 483 | private final Short tcpPort; |
| 484 | private final Type type; |
| 485 | |
| 486 | public TcpPortCriterion(Short tcpPort, Type type) { |
| 487 | this.tcpPort = tcpPort; |
| 488 | this.type = type; |
| 489 | } |
| 490 | |
| 491 | @Override |
| 492 | public Type type() { |
| 493 | return this.type; |
| 494 | } |
| 495 | |
| 496 | public Short tcpPort() { |
| 497 | return this.tcpPort; |
| 498 | } |
| 499 | |
| 500 | @Override |
| 501 | public String toString() { |
| 502 | return toStringHelper(type().toString()) |
| 503 | .add("tcpPort", tcpPort).toString(); |
| 504 | } |
| 505 | |
| 506 | @Override |
| 507 | public int hashCode() { |
| 508 | return Objects.hash(tcpPort, type); |
| 509 | } |
| 510 | |
| 511 | @Override |
| 512 | public boolean equals(Object obj) { |
| 513 | if (this == obj) { |
| 514 | return true; |
| 515 | } |
| 516 | if (obj instanceof TcpPortCriterion) { |
| 517 | TcpPortCriterion that = (TcpPortCriterion) obj; |
| 518 | return Objects.equals(tcpPort, that.tcpPort) && |
| 519 | Objects.equals(type, that.type); |
| 520 | |
| 521 | |
| 522 | } |
| 523 | return false; |
| 524 | } |
| 525 | } |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 526 | } |