blob: 684c5abc378aa116e7e86a75f3c4f8facadbd420 [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07002 * Copyright 2014 Open Networking Laboratory
Thomas Vachuska83e090e2014-10-22 14:25:35 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * 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
Thomas Vachuska83e090e2014-10-22 14:25:35 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * 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.
Thomas Vachuska83e090e2014-10-22 14:25:35 -070015 */
alshabib7410fea2014-09-16 13:48:39 -070016package org.onlab.onos.net.flow.criteria;
tom8bb16062014-09-12 14:47:46 -070017
alshabib99b8fdc2014-09-25 14:30:22 -070018import static com.google.common.base.MoreObjects.toStringHelper;
19
alshabibba5ac482014-10-02 17:15:20 -070020import java.util.Objects;
21
alshabib7b795492014-09-16 14:38:39 -070022import org.onlab.onos.net.PortNumber;
23import org.onlab.onos.net.flow.criteria.Criterion.Type;
Ayaka Koshibe1d56fe42014-09-19 16:51:58 -070024import org.onlab.packet.IpPrefix;
Ayaka Koshibea9c199f2014-09-16 16:21:40 -070025import org.onlab.packet.MacAddress;
26import org.onlab.packet.VlanId;
alshabib7b795492014-09-16 14:38:39 -070027
tom8bb16062014-09-12 14:47:46 -070028/**
29 * Factory class to create various traffic selection criteria.
30 */
31public final class Criteria {
32
alshabib7b795492014-09-16 14:38:39 -070033 //TODO: incomplete type implementation. Need to implement complete list from Criterion
34
tom8bb16062014-09-12 14:47:46 -070035 // Ban construction
36 private Criteria() {
37 }
38
39 /**
alshabib7b795492014-09-16 14:38:39 -070040 * Creates a match on IN_PORT field using the specified value.
41 *
42 * @param port inport value
43 * @return match criterion
44 */
45 public static Criterion matchInPort(PortNumber port) {
46 return new PortCriterion(port);
47 }
48
49 /**
tom8bb16062014-09-12 14:47:46 -070050 * Creates a match on ETH_SRC field using the specified value. This value
51 * may be a wildcard mask.
52 *
tomc104d282014-09-19 10:57:55 -070053 * @param mac MAC address value or wildcard mask
tom8bb16062014-09-12 14:47:46 -070054 * @return match criterion
55 */
Ayaka Koshibea9c199f2014-09-16 16:21:40 -070056 public static Criterion matchEthSrc(MacAddress mac) {
alshabib7b795492014-09-16 14:38:39 -070057 return new EthCriterion(mac, Type.ETH_SRC);
tom8bb16062014-09-12 14:47:46 -070058 }
59
alshabib369d2942014-09-12 17:59:35 -070060 /**
61 * Creates a match on ETH_DST field using the specified value. This value
62 * may be a wildcard mask.
63 *
tomc104d282014-09-19 10:57:55 -070064 * @param mac MAC address value or wildcard mask
alshabib369d2942014-09-12 17:59:35 -070065 * @return match criterion
66 */
Ayaka Koshibea9c199f2014-09-16 16:21:40 -070067 public static Criterion matchEthDst(MacAddress mac) {
alshabib7b795492014-09-16 14:38:39 -070068 return new EthCriterion(mac, Type.ETH_DST);
69 }
70
71 /**
72 * Creates a match on ETH_TYPE field using the specified value.
73 *
74 * @param ethType eth type value
75 * @return match criterion
76 */
77 public static Criterion matchEthType(Short ethType) {
78 return new EthTypeCriterion(ethType);
79 }
80
81 /**
82 * Creates a match on VLAN ID field using the specified value.
83 *
84 * @param vlanId vlan id value
85 * @return match criterion
86 */
Ayaka Koshibea9c199f2014-09-16 16:21:40 -070087 public static Criterion matchVlanId(VlanId vlanId) {
alshabib7b795492014-09-16 14:38:39 -070088 return new VlanIdCriterion(vlanId);
89 }
90
91 /**
92 * Creates a match on VLAN PCP field using the specified value.
93 *
94 * @param vlanPcp vlan pcp value
95 * @return match criterion
96 */
alshabibb45d1962014-09-18 14:25:45 -070097 public static Criterion matchVlanPcp(Byte vlanPcp) {
alshabib7b795492014-09-16 14:38:39 -070098 return new VlanPcpCriterion(vlanPcp);
99 }
100
101 /**
102 * Creates a match on IP proto field using the specified value.
103 *
104 * @param proto ip protocol value
105 * @return match criterion
106 */
107 public static Criterion matchIPProtocol(Byte proto) {
108 return new IPProtocolCriterion(proto);
109 }
110
111 /**
Sho SHIMIZUdfb9b362014-12-02 18:15:06 -0800112 * Creates a match on IP source field using the specified value.
alshabib7b795492014-09-16 14:38:39 -0700113 *
Sho SHIMIZUdfb9b362014-12-02 18:15:06 -0800114 * @param ip ip source value
alshabib7b795492014-09-16 14:38:39 -0700115 * @return match criterion
116 */
Ayaka Koshibe1d56fe42014-09-19 16:51:58 -0700117 public static Criterion matchIPSrc(IpPrefix ip) {
alshabib7b795492014-09-16 14:38:39 -0700118 return new IPCriterion(ip, Type.IPV4_SRC);
119 }
120
121 /**
Sho SHIMIZUdfb9b362014-12-02 18:15:06 -0800122 * Creates a match on IP destination field using the specified value.
alshabib7b795492014-09-16 14:38:39 -0700123 *
Sho SHIMIZUdfb9b362014-12-02 18:15:06 -0800124 * @param ip ip source value
alshabib7b795492014-09-16 14:38:39 -0700125 * @return match criterion
126 */
Ayaka Koshibe1d56fe42014-09-19 16:51:58 -0700127 public static Criterion matchIPDst(IpPrefix ip) {
alshabib7b795492014-09-16 14:38:39 -0700128 return new IPCriterion(ip, Type.IPV4_DST);
alshabib369d2942014-09-12 17:59:35 -0700129 }
130
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700131 /**
132 * Creates a match on TCP source port field using the specified value.
133 *
Yuta HIGUCHI5c947272014-11-03 21:39:21 -0800134 * @param tcpPort TCP source port
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700135 * @return match criterion
136 */
137 public static Criterion matchTcpSrc(Short tcpPort) {
138 return new TcpPortCriterion(tcpPort, Type.TCP_SRC);
139 }
140
141 /**
142 * Creates a match on TCP destination port field using the specified value.
143 *
Yuta HIGUCHI5c947272014-11-03 21:39:21 -0800144 * @param tcpPort TCP destination port
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700145 * @return match criterion
146 */
147 public static Criterion matchTcpDst(Short tcpPort) {
148 return new TcpPortCriterion(tcpPort, Type.TCP_DST);
149 }
alshabib369d2942014-09-12 17:59:35 -0700150
Marc De Leenheer49087752014-10-23 13:54:09 -0700151 /**
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800152 * Creates a match on MPLS label.
153 * @param mplsLabel MPLS label
154 * @return match criterion
155 */
156
157 public static Criterion matchMplsLabel(Integer mplsLabel) {
158 return new MplsCriterion(mplsLabel);
159 }
160
161 /**
Marc De Leenheer49087752014-10-23 13:54:09 -0700162 * Creates a match on lambda field using the specified value.
163 *
Sho SHIMIZUa66cb122014-12-02 18:11:15 -0800164 * @param lambda lambda to match on
Marc De Leenheer49087752014-10-23 13:54:09 -0700165 * @return match criterion
166 */
167 public static Criterion matchLambda(Short lambda) {
168 return new LambdaCriterion(lambda, Type.OCH_SIGID);
169 }
170
171 /**
Sho SHIMIZUa66cb122014-12-02 18:11:15 -0800172 * Creates a match on optical signal type using the specified value.
Praseed Balakrishnan64369da2014-10-23 15:55:20 -0700173 *
Sho SHIMIZUa66cb122014-12-02 18:11:15 -0800174 * @param sigType optical signal type
Praseed Balakrishnan64369da2014-10-23 15:55:20 -0700175 * @return match criterion
176 */
Praseed Balakrishnan2dd5abd2014-11-03 14:56:28 -0800177 public static Criterion matchOpticalSignalType(Short sigType) {
178 return new OpticalSignalTypeCriterion(sigType, Type.OCH_SIGTYPE);
Praseed Balakrishnan64369da2014-10-23 15:55:20 -0700179 }
180
Praseed Balakrishnan64369da2014-10-23 15:55:20 -0700181 /**
Sho SHIMIZU06596e32014-12-02 18:07:50 -0800182 * Implementation of input port criterion.
alshabib7b795492014-09-16 14:38:39 -0700183 */
alshabib7b795492014-09-16 14:38:39 -0700184 public static final class PortCriterion implements Criterion {
185 private final PortNumber port;
186
187 public PortCriterion(PortNumber port) {
188 this.port = port;
189 }
190
191 @Override
192 public Type type() {
193 return Type.IN_PORT;
194 }
195
196 public PortNumber port() {
197 return this.port;
198 }
alshabib99b8fdc2014-09-25 14:30:22 -0700199
200 @Override
201 public String toString() {
202 return toStringHelper(type().toString())
203 .add("port", port).toString();
204 }
alshabibba5ac482014-10-02 17:15:20 -0700205
206 @Override
207 public int hashCode() {
Thomas Vachuska9b2da212014-11-10 19:30:25 -0800208 return Objects.hash(type(), port);
alshabibba5ac482014-10-02 17:15:20 -0700209 }
210
211 @Override
212 public boolean equals(Object obj) {
213 if (this == obj) {
214 return true;
215 }
216 if (obj instanceof PortCriterion) {
217 PortCriterion that = (PortCriterion) obj;
alshabib2020b892014-10-20 15:47:08 -0700218 return Objects.equals(port, that.port) &&
219 Objects.equals(this.type(), that.type());
alshabibba5ac482014-10-02 17:15:20 -0700220
221 }
222 return false;
223 }
224
alshabib7b795492014-09-16 14:38:39 -0700225 }
226
227
Sho SHIMIZU06596e32014-12-02 18:07:50 -0800228 /**
229 * Implementation of MAC address criterion.
230 */
alshabib7b795492014-09-16 14:38:39 -0700231 public static final class EthCriterion implements Criterion {
Ayaka Koshibea9c199f2014-09-16 16:21:40 -0700232 private final MacAddress mac;
alshabib7b795492014-09-16 14:38:39 -0700233 private final Type type;
234
Ayaka Koshibea9c199f2014-09-16 16:21:40 -0700235 public EthCriterion(MacAddress mac, Type type) {
alshabib7b795492014-09-16 14:38:39 -0700236 this.mac = mac;
237 this.type = type;
238 }
239
240 @Override
241 public Type type() {
242 return this.type;
243 }
244
Ayaka Koshibea9c199f2014-09-16 16:21:40 -0700245 public MacAddress mac() {
alshabib7b795492014-09-16 14:38:39 -0700246 return this.mac;
247 }
alshabib99b8fdc2014-09-25 14:30:22 -0700248
249 @Override
250 public String toString() {
251 return toStringHelper(type().toString())
252 .add("mac", mac).toString();
253 }
254
alshabibba5ac482014-10-02 17:15:20 -0700255 @Override
256 public int hashCode() {
Thomas Vachuska9b2da212014-11-10 19:30:25 -0800257 return Objects.hash(type, mac);
alshabibba5ac482014-10-02 17:15:20 -0700258 }
259
260 @Override
261 public boolean equals(Object obj) {
262 if (this == obj) {
263 return true;
264 }
265 if (obj instanceof EthCriterion) {
266 EthCriterion that = (EthCriterion) obj;
267 return Objects.equals(mac, that.mac) &&
268 Objects.equals(type, that.type);
269
270
271 }
272 return false;
273 }
274
275
alshabib7b795492014-09-16 14:38:39 -0700276 }
277
Sho SHIMIZU06596e32014-12-02 18:07:50 -0800278 /**
279 * Implementation of Ethernet type criterion.
280 */
alshabib7b795492014-09-16 14:38:39 -0700281 public static final class EthTypeCriterion implements Criterion {
282
283 private final Short ethType;
284
285 public EthTypeCriterion(Short ethType) {
286 this.ethType = ethType;
287 }
288
289 @Override
290 public Type type() {
291 return Type.ETH_TYPE;
292 }
293
294 public Short ethType() {
295 return ethType;
296 }
297
alshabib99b8fdc2014-09-25 14:30:22 -0700298 @Override
299 public String toString() {
300 return toStringHelper(type().toString())
301 .add("ethType", Long.toHexString(ethType)).toString();
302 }
303
alshabibba5ac482014-10-02 17:15:20 -0700304 @Override
305 public int hashCode() {
Thomas Vachuska9b2da212014-11-10 19:30:25 -0800306 return Objects.hash(type(), ethType);
alshabibba5ac482014-10-02 17:15:20 -0700307 }
308
309 @Override
310 public boolean equals(Object obj) {
311 if (this == obj) {
312 return true;
313 }
314 if (obj instanceof EthTypeCriterion) {
315 EthTypeCriterion that = (EthTypeCriterion) obj;
alshabib2020b892014-10-20 15:47:08 -0700316 return Objects.equals(ethType, that.ethType) &&
317 Objects.equals(this.type(), that.type());
alshabibba5ac482014-10-02 17:15:20 -0700318
319
320 }
321 return false;
322 }
323
alshabib7b795492014-09-16 14:38:39 -0700324 }
325
Sho SHIMIZU06596e32014-12-02 18:07:50 -0800326 /**
327 * Implementation of IP address criterion.
328 */
alshabib7b795492014-09-16 14:38:39 -0700329 public static final class IPCriterion implements Criterion {
330
Ayaka Koshibe1d56fe42014-09-19 16:51:58 -0700331 private final IpPrefix ip;
alshabib7b795492014-09-16 14:38:39 -0700332 private final Type type;
333
Ayaka Koshibe1d56fe42014-09-19 16:51:58 -0700334 public IPCriterion(IpPrefix ip, Type type) {
alshabib7b795492014-09-16 14:38:39 -0700335 this.ip = ip;
336 this.type = type;
337 }
338
339 @Override
340 public Type type() {
341 return this.type;
342 }
343
Ayaka Koshibe1d56fe42014-09-19 16:51:58 -0700344 public IpPrefix ip() {
alshabib7b795492014-09-16 14:38:39 -0700345 return this.ip;
346 }
347
alshabib99b8fdc2014-09-25 14:30:22 -0700348 @Override
349 public String toString() {
350 return toStringHelper(type().toString())
351 .add("ip", ip).toString();
352 }
alshabib7b795492014-09-16 14:38:39 -0700353
alshabibba5ac482014-10-02 17:15:20 -0700354 @Override
355 public int hashCode() {
Thomas Vachuska9b2da212014-11-10 19:30:25 -0800356 return Objects.hash(type, ip);
alshabibba5ac482014-10-02 17:15:20 -0700357 }
358
359 @Override
360 public boolean equals(Object obj) {
361 if (this == obj) {
362 return true;
363 }
364 if (obj instanceof IPCriterion) {
365 IPCriterion that = (IPCriterion) obj;
366 return Objects.equals(ip, that.ip) &&
367 Objects.equals(type, that.type);
368
369
370 }
371 return false;
372 }
373
alshabib7b795492014-09-16 14:38:39 -0700374 }
375
Sho SHIMIZU06596e32014-12-02 18:07:50 -0800376 /**
377 * Implementation of Internet Protocol Number criterion.
378 */
alshabib7b795492014-09-16 14:38:39 -0700379 public static final class IPProtocolCriterion implements Criterion {
380
381 private final Byte proto;
382
383 public IPProtocolCriterion(Byte protocol) {
384 this.proto = protocol;
385 }
386
387 @Override
388 public Type type() {
389 return Type.IP_PROTO;
390 }
391
392 public Byte protocol() {
393 return proto;
394 }
395
alshabib99b8fdc2014-09-25 14:30:22 -0700396 @Override
397 public String toString() {
398 return toStringHelper(type().toString())
399 .add("protocol", Long.toHexString(proto)).toString();
400 }
401
alshabibba5ac482014-10-02 17:15:20 -0700402 @Override
403 public int hashCode() {
Thomas Vachuska9b2da212014-11-10 19:30:25 -0800404 return Objects.hash(type(), proto);
alshabibba5ac482014-10-02 17:15:20 -0700405 }
406
407 @Override
408 public boolean equals(Object obj) {
409 if (this == obj) {
410 return true;
411 }
412 if (obj instanceof IPProtocolCriterion) {
413 IPProtocolCriterion that = (IPProtocolCriterion) obj;
414 return Objects.equals(proto, that.proto);
415
416
417 }
418 return false;
419 }
420
alshabib7b795492014-09-16 14:38:39 -0700421 }
422
Sho SHIMIZU06596e32014-12-02 18:07:50 -0800423 /**
424 * Implementation of VLAN priority criterion.
425 */
alshabib7b795492014-09-16 14:38:39 -0700426 public static final class VlanPcpCriterion implements Criterion {
427
428 private final Byte vlanPcp;
429
430 public VlanPcpCriterion(Byte vlanPcp) {
431 this.vlanPcp = vlanPcp;
432 }
433
434 @Override
435 public Type type() {
436 return Type.VLAN_PCP;
437 }
438
alshabib35edb1a2014-09-16 17:44:44 -0700439 public Byte priority() {
alshabib7b795492014-09-16 14:38:39 -0700440 return vlanPcp;
441 }
442
alshabib99b8fdc2014-09-25 14:30:22 -0700443 @Override
444 public String toString() {
445 return toStringHelper(type().toString())
446 .add("pcp", Long.toHexString(vlanPcp)).toString();
447 }
448
alshabibba5ac482014-10-02 17:15:20 -0700449 @Override
450 public int hashCode() {
Thomas Vachuska9b2da212014-11-10 19:30:25 -0800451 return Objects.hash(type(), vlanPcp);
alshabibba5ac482014-10-02 17:15:20 -0700452 }
453
454 @Override
455 public boolean equals(Object obj) {
456 if (this == obj) {
457 return true;
458 }
459 if (obj instanceof VlanPcpCriterion) {
460 VlanPcpCriterion that = (VlanPcpCriterion) obj;
alshabib2020b892014-10-20 15:47:08 -0700461 return Objects.equals(vlanPcp, that.vlanPcp) &&
462 Objects.equals(this.type(), that.type());
alshabibba5ac482014-10-02 17:15:20 -0700463
464
465 }
466 return false;
467 }
468
alshabib7b795492014-09-16 14:38:39 -0700469 }
470
Sho SHIMIZU06596e32014-12-02 18:07:50 -0800471 /**
472 * Implementation of VLAN ID criterion.
473 */
alshabib7b795492014-09-16 14:38:39 -0700474 public static final class VlanIdCriterion implements Criterion {
475
476
Ayaka Koshibea9c199f2014-09-16 16:21:40 -0700477 private final VlanId vlanId;
alshabib7b795492014-09-16 14:38:39 -0700478
Ayaka Koshibea9c199f2014-09-16 16:21:40 -0700479 public VlanIdCriterion(VlanId vlanId) {
alshabib7b795492014-09-16 14:38:39 -0700480 this.vlanId = vlanId;
481 }
482
483 @Override
484 public Type type() {
485 return Type.VLAN_VID;
486 }
487
Ayaka Koshibea9c199f2014-09-16 16:21:40 -0700488 public VlanId vlanId() {
alshabib7b795492014-09-16 14:38:39 -0700489 return vlanId;
490 }
491
alshabib99b8fdc2014-09-25 14:30:22 -0700492 @Override
493 public String toString() {
494 return toStringHelper(type().toString())
495 .add("id", vlanId).toString();
496 }
497
alshabibba5ac482014-10-02 17:15:20 -0700498 @Override
499 public int hashCode() {
Thomas Vachuska9b2da212014-11-10 19:30:25 -0800500 return Objects.hash(type(), vlanId);
alshabibba5ac482014-10-02 17:15:20 -0700501 }
502
503 @Override
504 public boolean equals(Object obj) {
505 if (this == obj) {
506 return true;
507 }
508 if (obj instanceof VlanIdCriterion) {
509 VlanIdCriterion that = (VlanIdCriterion) obj;
alshabib2020b892014-10-20 15:47:08 -0700510 return Objects.equals(vlanId, that.vlanId) &&
511 Objects.equals(this.type(), that.type());
alshabibba5ac482014-10-02 17:15:20 -0700512
513
514 }
515 return false;
516 }
517
alshabib7b795492014-09-16 14:38:39 -0700518 }
519
Sho SHIMIZU06596e32014-12-02 18:07:50 -0800520 /**
521 * Implementation of TCP port criterion.
522 */
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700523 public static final class TcpPortCriterion implements Criterion {
524
525 private final Short tcpPort;
526 private final Type type;
527
528 public TcpPortCriterion(Short tcpPort, Type type) {
529 this.tcpPort = tcpPort;
530 this.type = type;
531 }
532
533 @Override
534 public Type type() {
535 return this.type;
536 }
537
538 public Short tcpPort() {
539 return this.tcpPort;
540 }
541
542 @Override
543 public String toString() {
544 return toStringHelper(type().toString())
545 .add("tcpPort", tcpPort).toString();
546 }
547
548 @Override
549 public int hashCode() {
Thomas Vachuska9b2da212014-11-10 19:30:25 -0800550 return Objects.hash(type, tcpPort);
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700551 }
552
553 @Override
554 public boolean equals(Object obj) {
555 if (this == obj) {
556 return true;
557 }
558 if (obj instanceof TcpPortCriterion) {
559 TcpPortCriterion that = (TcpPortCriterion) obj;
560 return Objects.equals(tcpPort, that.tcpPort) &&
561 Objects.equals(type, that.type);
562
563
564 }
565 return false;
566 }
567 }
Marc De Leenheer49087752014-10-23 13:54:09 -0700568
Sho SHIMIZU06596e32014-12-02 18:07:50 -0800569 /**
570 * Implementation of MPLS tag criterion.
571 */
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800572 public static final class MplsCriterion implements Criterion {
573
574 private final Integer mplsLabel;
575
576 public MplsCriterion(Integer mplsLabel) {
577 this.mplsLabel = mplsLabel;
578 }
579
580 @Override
581 public Type type() {
582 return Type.MPLS_LABEL;
583 }
584
585 public Integer label() {
586 return mplsLabel;
587 }
588
589 @Override
590 public String toString() {
591 return toStringHelper(type().toString())
592 .add("mpls", mplsLabel.intValue()).toString();
593 }
594
595 @Override
596 public int hashCode() {
597 return Objects.hash(mplsLabel, type());
598 }
599
600 @Override
601 public boolean equals(Object obj) {
602 if (this == obj) {
603 return true;
604 }
605 if (obj instanceof MplsCriterion) {
606 MplsCriterion that = (MplsCriterion) obj;
607 return Objects.equals(mplsLabel, that.mplsLabel) &&
608 Objects.equals(this.type(), that.type());
609
610
611 }
612 return false;
613 }
614
615 }
616
Sho SHIMIZU06596e32014-12-02 18:07:50 -0800617 /**
618 * Implementation of lambda (wavelength) criterion.
619 */
Marc De Leenheer49087752014-10-23 13:54:09 -0700620 public static final class LambdaCriterion implements Criterion {
621
622 private final short lambda;
623 private final Type type;
624
625 public LambdaCriterion(short lambda, Type type) {
626 this.lambda = lambda;
627 this.type = type;
628 }
629
630 @Override
631 public Type type() {
632 return this.type;
633 }
634
635 public Short lambda() {
636 return this.lambda;
637 }
638
639 @Override
640 public String toString() {
641 return toStringHelper(type().toString())
642 .add("lambda", lambda).toString();
643 }
644
645 @Override
646 public int hashCode() {
Thomas Vachuska9b2da212014-11-10 19:30:25 -0800647 return Objects.hash(type, lambda);
Marc De Leenheer49087752014-10-23 13:54:09 -0700648 }
649
650 @Override
651 public boolean equals(Object obj) {
652 if (this == obj) {
653 return true;
654 }
655 if (obj instanceof LambdaCriterion) {
656 LambdaCriterion that = (LambdaCriterion) obj;
657 return Objects.equals(lambda, that.lambda) &&
658 Objects.equals(type, that.type);
659 }
660 return false;
661 }
662 }
663
Sho SHIMIZU06596e32014-12-02 18:07:50 -0800664 /**
665 * Implementation of optical signal type criterion.
666 */
Praseed Balakrishnan64369da2014-10-23 15:55:20 -0700667 public static final class OpticalSignalTypeCriterion implements Criterion {
668
Praseed Balakrishnan2dd5abd2014-11-03 14:56:28 -0800669 private final Short signalType;
Praseed Balakrishnan64369da2014-10-23 15:55:20 -0700670 private final Type type;
671
Praseed Balakrishnan2dd5abd2014-11-03 14:56:28 -0800672 public OpticalSignalTypeCriterion(Short signalType, Type type) {
Praseed Balakrishnan64369da2014-10-23 15:55:20 -0700673 this.signalType = signalType;
674 this.type = type;
675 }
676
677 @Override
678 public Type type() {
679 return this.type;
680 }
681
Praseed Balakrishnan2dd5abd2014-11-03 14:56:28 -0800682 public Short signalType() {
Praseed Balakrishnan64369da2014-10-23 15:55:20 -0700683 return this.signalType;
684 }
685
686 @Override
687 public String toString() {
688 return toStringHelper(type().toString())
689 .add("signalType", signalType).toString();
690 }
691
692 @Override
693 public int hashCode() {
Thomas Vachuska9b2da212014-11-10 19:30:25 -0800694 return Objects.hash(type, signalType);
Praseed Balakrishnan64369da2014-10-23 15:55:20 -0700695 }
696
697 @Override
698 public boolean equals(Object obj) {
699 if (this == obj) {
700 return true;
701 }
702 if (obj instanceof OpticalSignalTypeCriterion) {
703 OpticalSignalTypeCriterion that = (OpticalSignalTypeCriterion) obj;
704 return Objects.equals(signalType, that.signalType) &&
705 Objects.equals(type, that.type);
706 }
707 return false;
708 }
709 }
710
tom8bb16062014-09-12 14:47:46 -0700711}