blob: 0252cfbc398a06aa6f76f1926d4a94174595e43a [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
Ray Milkey34c95902015-04-15 09:47:53 -07002 * Copyright 2014-2015 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 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.flow.criteria;
tom8bb16062014-09-12 14:47:46 -070017
alshabibcaf1ca22015-06-25 15:18:16 -070018import org.onlab.packet.EthType;
Hyunsun Mooncf732fb2015-08-22 21:04:23 -070019import org.onlab.packet.Ip6Address;
20import org.onlab.packet.IpPrefix;
21import org.onlab.packet.MacAddress;
22import org.onlab.packet.MplsLabel;
23import org.onlab.packet.TpPort;
24import org.onlab.packet.VlanId;
Sho SHIMIZUefc2e282015-05-04 15:26:23 -070025import org.onosproject.net.IndexedLambda;
Sho SHIMIZU084c4ca2015-05-04 11:52:51 -070026import org.onosproject.net.Lambda;
27import org.onosproject.net.OchSignal;
Brian O'Connorabafb502014-12-02 22:26:20 -080028import org.onosproject.net.PortNumber;
29import org.onosproject.net.flow.criteria.Criterion.Type;
Sho SHIMIZU585bed92015-05-13 11:08:45 -070030import org.onosproject.net.OchSignalType;
alshabib7b795492014-09-16 14:38:39 -070031
tom8bb16062014-09-12 14:47:46 -070032/**
33 * Factory class to create various traffic selection criteria.
34 */
35public final class Criteria {
36
alshabib7b795492014-09-16 14:38:39 -070037 //TODO: incomplete type implementation. Need to implement complete list from Criterion
38
tom8bb16062014-09-12 14:47:46 -070039 // Ban construction
40 private Criteria() {
41 }
42
43 /**
alshabib7b795492014-09-16 14:38:39 -070044 * Creates a match on IN_PORT field using the specified value.
45 *
46 * @param port inport value
47 * @return match criterion
48 */
49 public static Criterion matchInPort(PortNumber port) {
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -080050 return new PortCriterion(port, Type.IN_PORT);
51 }
52
53 /**
54 * Creates a match on IN_PHY_PORT field using the specified value.
55 *
56 * @param port inport value
57 * @return match criterion
58 */
59 public static Criterion matchInPhyPort(PortNumber port) {
60 return new PortCriterion(port, Type.IN_PHY_PORT);
61 }
62
63 /**
64 * Creates a match on METADATA field using the specified value.
65 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -080066 * @param metadata metadata value (64 bits data)
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -080067 * @return match criterion
68 */
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -080069 public static Criterion matchMetadata(long metadata) {
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -080070 return new MetadataCriterion(metadata);
alshabib7b795492014-09-16 14:38:39 -070071 }
72
73 /**
alshabib369d2942014-09-12 17:59:35 -070074 * Creates a match on ETH_DST field using the specified value. This value
75 * may be a wildcard mask.
76 *
tomc104d282014-09-19 10:57:55 -070077 * @param mac MAC address value or wildcard mask
alshabib369d2942014-09-12 17:59:35 -070078 * @return match criterion
79 */
Ayaka Koshibea9c199f2014-09-16 16:21:40 -070080 public static Criterion matchEthDst(MacAddress mac) {
alshabib7b795492014-09-16 14:38:39 -070081 return new EthCriterion(mac, Type.ETH_DST);
82 }
83
84 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -080085 * Creates a match on ETH_SRC field using the specified value. This value
86 * may be a wildcard mask.
87 *
88 * @param mac MAC address value or wildcard mask
89 * @return match criterion
90 */
91 public static Criterion matchEthSrc(MacAddress mac) {
92 return new EthCriterion(mac, Type.ETH_SRC);
93 }
94
95 /**
alshabib7b795492014-09-16 14:38:39 -070096 * Creates a match on ETH_TYPE field using the specified value.
97 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -080098 * @param ethType eth type value (16 bits unsigned integer)
alshabib7b795492014-09-16 14:38:39 -070099 * @return match criterion
100 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800101 public static Criterion matchEthType(int ethType) {
alshabib7b795492014-09-16 14:38:39 -0700102 return new EthTypeCriterion(ethType);
103 }
104
105 /**
alshabibcaf1ca22015-06-25 15:18:16 -0700106 * Creates a match on ETH_TYPE field using the specified value.
107 *
108 * @param ethType eth type value
109 * @return match criterion
110 */
111 public static Criterion matchEthType(EthType ethType) {
112 return new EthTypeCriterion(ethType);
113 }
114
115 /**
alshabib7b795492014-09-16 14:38:39 -0700116 * Creates a match on VLAN ID field using the specified value.
117 *
118 * @param vlanId vlan id value
119 * @return match criterion
120 */
Ayaka Koshibea9c199f2014-09-16 16:21:40 -0700121 public static Criterion matchVlanId(VlanId vlanId) {
alshabib7b795492014-09-16 14:38:39 -0700122 return new VlanIdCriterion(vlanId);
123 }
124
125 /**
126 * Creates a match on VLAN PCP field using the specified value.
127 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800128 * @param vlanPcp vlan pcp value (3 bits)
alshabib7b795492014-09-16 14:38:39 -0700129 * @return match criterion
130 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800131 public static Criterion matchVlanPcp(byte vlanPcp) {
alshabib7b795492014-09-16 14:38:39 -0700132 return new VlanPcpCriterion(vlanPcp);
133 }
134
135 /**
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800136 * Creates a match on IP DSCP field using the specified value.
137 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800138 * @param ipDscp ip dscp value (6 bits)
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800139 * @return match criterion
140 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800141 public static Criterion matchIPDscp(byte ipDscp) {
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800142 return new IPDscpCriterion(ipDscp);
143 }
144
145 /**
146 * Creates a match on IP ECN field using the specified value.
147 *
Pavlin Radoslavovab8553a2015-02-20 14:13:50 -0800148 * @param ipEcn ip ecn value (2 bits)
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800149 * @return match criterion
150 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800151 public static Criterion matchIPEcn(byte ipEcn) {
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800152 return new IPEcnCriterion(ipEcn);
153 }
154
155 /**
alshabib7b795492014-09-16 14:38:39 -0700156 * Creates a match on IP proto field using the specified value.
157 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800158 * @param proto ip protocol value (8 bits unsigned integer)
alshabib7b795492014-09-16 14:38:39 -0700159 * @return match criterion
160 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800161 public static Criterion matchIPProtocol(short proto) {
alshabib7b795492014-09-16 14:38:39 -0700162 return new IPProtocolCriterion(proto);
163 }
164
165 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800166 * Creates a match on IPv4 source field using the specified value.
alshabib7b795492014-09-16 14:38:39 -0700167 *
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800168 * @param ip ipv4 source value
alshabib7b795492014-09-16 14:38:39 -0700169 * @return match criterion
170 */
Ayaka Koshibe1d56fe42014-09-19 16:51:58 -0700171 public static Criterion matchIPSrc(IpPrefix ip) {
alshabib7b795492014-09-16 14:38:39 -0700172 return new IPCriterion(ip, Type.IPV4_SRC);
173 }
174
175 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800176 * Creates a match on IPv4 destination field using the specified value.
alshabib7b795492014-09-16 14:38:39 -0700177 *
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800178 * @param ip ipv4 source value
alshabib7b795492014-09-16 14:38:39 -0700179 * @return match criterion
180 */
Ayaka Koshibe1d56fe42014-09-19 16:51:58 -0700181 public static Criterion matchIPDst(IpPrefix ip) {
alshabib7b795492014-09-16 14:38:39 -0700182 return new IPCriterion(ip, Type.IPV4_DST);
alshabib369d2942014-09-12 17:59:35 -0700183 }
184
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700185 /**
186 * Creates a match on TCP source port field using the specified value.
187 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700188 * @param tcpPort TCP source port
189 * @return match criterion
190 * @deprecated in Drake release
191 */
192 @Deprecated
193 public static Criterion matchTcpSrc(short tcpPort) {
194 return new TcpPortCriterion(TpPort.tpPort(tcpPort), Type.TCP_SRC);
195 }
196
197 /**
198 * Creates a match on TCP source port field using the specified value.
199 *
200 * @param tcpPort TCP source port
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700201 * @return match criterion
202 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700203 public static Criterion matchTcpSrc(TpPort tcpPort) {
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700204 return new TcpPortCriterion(tcpPort, Type.TCP_SRC);
205 }
206
207 /**
208 * Creates a match on TCP destination port field using the specified value.
209 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700210 * @param tcpPort TCP destination port
211 * @return match criterion
212 * @deprecated in Drake release
213 */
214 @Deprecated
215 public static Criterion matchTcpDst(short tcpPort) {
216 return new TcpPortCriterion(TpPort.tpPort(tcpPort), Type.TCP_DST);
217 }
218
219 /**
220 * Creates a match on TCP destination port field using the specified value.
221 *
222 * @param tcpPort TCP destination port
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700223 * @return match criterion
224 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700225 public static Criterion matchTcpDst(TpPort tcpPort) {
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700226 return new TcpPortCriterion(tcpPort, Type.TCP_DST);
227 }
alshabib369d2942014-09-12 17:59:35 -0700228
Marc De Leenheer49087752014-10-23 13:54:09 -0700229 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800230 * Creates a match on UDP source port field using the specified value.
231 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700232 * @param udpPort UDP source port
233 * @return match criterion
234 * @deprecated in Drake release
235 */
236 @Deprecated
237 public static Criterion matchUdpSrc(short udpPort) {
238 return new UdpPortCriterion(TpPort.tpPort(udpPort), Type.UDP_SRC);
239 }
240
241 /**
242 * Creates a match on UDP source port field using the specified value.
243 *
244 * @param udpPort UDP source port
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800245 * @return match criterion
246 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700247 public static Criterion matchUdpSrc(TpPort udpPort) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800248 return new UdpPortCriterion(udpPort, Type.UDP_SRC);
249 }
250
251 /**
252 * Creates a match on UDP destination port field using the specified value.
253 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700254 * @param udpPort UDP destination port
255 * @return match criterion
256 * @deprecated in Drake release
257 */
258 @Deprecated
259 public static Criterion matchUdpDst(short udpPort) {
260 return new UdpPortCriterion(TpPort.tpPort(udpPort), Type.UDP_DST);
261 }
262
263 /**
264 * Creates a match on UDP destination port field using the specified value.
265 *
266 * @param udpPort UDP destination port
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800267 * @return match criterion
268 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700269 public static Criterion matchUdpDst(TpPort udpPort) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800270 return new UdpPortCriterion(udpPort, Type.UDP_DST);
271 }
272
273 /**
274 * Creates a match on SCTP source port field using the specified value.
275 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700276 * @param sctpPort SCTP source port
277 * @return match criterion
278 * @deprecated in Drake release
279 */
280 @Deprecated
281 public static Criterion matchSctpSrc(short sctpPort) {
282 return new SctpPortCriterion(TpPort.tpPort(sctpPort), Type.SCTP_SRC);
283 }
284
285 /**
286 * Creates a match on SCTP source port field using the specified value.
287 *
288 * @param sctpPort SCTP source port
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800289 * @return match criterion
290 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700291 public static Criterion matchSctpSrc(TpPort sctpPort) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800292 return new SctpPortCriterion(sctpPort, Type.SCTP_SRC);
293 }
294
295 /**
296 * Creates a match on SCTP destination port field using the specified
297 * value.
298 *
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700299 * @param sctpPort SCTP destination port
300 * @return match criterion
301 * @deprecated in Drake release
302 */
303 @Deprecated
304 public static Criterion matchSctpDst(short sctpPort) {
305 return new SctpPortCriterion(TpPort.tpPort(sctpPort), Type.SCTP_DST);
306 }
307
308 /**
309 * Creates a match on SCTP destination port field using the specified
310 * value.
311 *
312 * @param sctpPort SCTP destination port
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800313 * @return match criterion
314 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700315 public static Criterion matchSctpDst(TpPort sctpPort) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800316 return new SctpPortCriterion(sctpPort, Type.SCTP_DST);
317 }
318
319 /**
320 * Creates a match on ICMP type field using the specified value.
321 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800322 * @param icmpType ICMP type (8 bits unsigned integer)
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800323 * @return match criterion
324 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800325 public static Criterion matchIcmpType(short icmpType) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800326 return new IcmpTypeCriterion(icmpType);
327 }
328
329 /**
330 * Creates a match on ICMP code field using the specified value.
331 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800332 * @param icmpCode ICMP code (8 bits unsigned integer)
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800333 * @return match criterion
334 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800335 public static Criterion matchIcmpCode(short icmpCode) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800336 return new IcmpCodeCriterion(icmpCode);
337 }
338
339 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800340 * Creates a match on IPv6 source field using the specified value.
341 *
342 * @param ip ipv6 source value
343 * @return match criterion
344 */
345 public static Criterion matchIPv6Src(IpPrefix ip) {
346 return new IPCriterion(ip, Type.IPV6_SRC);
347 }
348
349 /**
350 * Creates a match on IPv6 destination field using the specified value.
351 *
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800352 * @param ip ipv6 destination value
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800353 * @return match criterion
354 */
355 public static Criterion matchIPv6Dst(IpPrefix ip) {
356 return new IPCriterion(ip, Type.IPV6_DST);
357 }
358
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800359 /**
360 * Creates a match on IPv6 flow label field using the specified value.
361 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800362 * @param flowLabel IPv6 flow label (20 bits)
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800363 * @return match criterion
364 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800365 public static Criterion matchIPv6FlowLabel(int flowLabel) {
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800366 return new IPv6FlowLabelCriterion(flowLabel);
367 }
368
369 /**
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800370 * Creates a match on ICMPv6 type field using the specified value.
371 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800372 * @param icmpv6Type ICMPv6 type (8 bits unsigned integer)
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800373 * @return match criterion
374 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800375 public static Criterion matchIcmpv6Type(short icmpv6Type) {
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800376 return new Icmpv6TypeCriterion(icmpv6Type);
377 }
378
379 /**
380 * Creates a match on ICMPv6 code field using the specified value.
381 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800382 * @param icmpv6Code ICMPv6 code (8 bits unsigned integer)
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800383 * @return match criterion
384 */
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800385 public static Criterion matchIcmpv6Code(short icmpv6Code) {
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800386 return new Icmpv6CodeCriterion(icmpv6Code);
387 }
388
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800389 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800390 * Creates a match on IPv6 Neighbor Discovery target address using the
391 * specified value.
392 *
393 * @param targetAddress IPv6 Neighbor Discovery target address
394 * @return match criterion
395 */
396 public static Criterion matchIPv6NDTargetAddress(Ip6Address targetAddress) {
397 return new IPv6NDTargetAddressCriterion(targetAddress);
398 }
399
400 /**
401 * Creates a match on IPv6 Neighbor Discovery source link-layer address
402 * using the specified value.
403 *
404 * @param mac IPv6 Neighbor Discovery source link-layer address
405 * @return match criterion
406 */
407 public static Criterion matchIPv6NDSourceLinkLayerAddress(MacAddress mac) {
408 return new IPv6NDLinkLayerAddressCriterion(mac, Type.IPV6_ND_SLL);
409 }
410
411 /**
412 * Creates a match on IPv6 Neighbor Discovery target link-layer address
413 * using the specified value.
414 *
415 * @param mac IPv6 Neighbor Discovery target link-layer address
416 * @return match criterion
417 */
418 public static Criterion matchIPv6NDTargetLinkLayerAddress(MacAddress mac) {
419 return new IPv6NDLinkLayerAddressCriterion(mac, Type.IPV6_ND_TLL);
420 }
421
422 /**
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800423 * Creates a match on MPLS label.
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800424 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800425 * @param mplsLabel MPLS label (20 bits)
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800426 * @return match criterion
427 */
Michele Santuari4b6019e2014-12-19 11:31:45 +0100428 public static Criterion matchMplsLabel(MplsLabel mplsLabel) {
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800429 return new MplsCriterion(mplsLabel);
430 }
431
432 /**
Saurav Dasffc5bbc2015-08-18 23:30:19 -0700433 * Creates a match on MPLS Bottom-of-Stack indicator bit.
434 *
435 * @param mplsBos boolean value indicating true (BOS=1) or false (BOS=0)
436 * @return match criterion
437 */
438 public static Criterion matchMplsLabel(boolean mplsBos) {
439 return new MplsBosCriterion(mplsBos);
440 }
441
442 /**
Hyunsun Moona08c5d02015-07-14 17:53:00 -0700443 * Creates a match on Tunnel ID.
444 *
445 * @param tunnelId Tunnel ID (64 bits)
446 * @return match criterion
447 */
448 public static Criterion matchTunnelId(long tunnelId) {
449 return new TunnelIdCriterion(tunnelId);
450 }
451
452 /**
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800453 * Creates a match on IPv6 Extension Header pseudo-field fiags.
454 * Those are defined in Criterion.IPv6ExthdrFlags.
455 *
456 * @param exthdrFlags IPv6 Extension Header pseudo-field flags (16 bits)
457 * @return match criterion
458 */
459 public static Criterion matchIPv6ExthdrFlags(int exthdrFlags) {
460 return new IPv6ExthdrFlagsCriterion(exthdrFlags);
461 }
462
463 /**
Marc De Leenheer49087752014-10-23 13:54:09 -0700464 * Creates a match on lambda field using the specified value.
465 *
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800466 * @param lambda lambda to match on (16 bits unsigned integer)
Marc De Leenheer49087752014-10-23 13:54:09 -0700467 * @return match criterion
Sho SHIMIZU2a9c3af2015-05-06 10:45:42 -0700468 * @deprecated in Cardinal Release. Use {@link #matchLambda(Lambda)} instead.
Marc De Leenheer49087752014-10-23 13:54:09 -0700469 */
Sho SHIMIZUefc2e282015-05-04 15:26:23 -0700470 @Deprecated
Pavlin Radoslavovf3b69332015-02-06 15:47:05 -0800471 public static Criterion matchLambda(int lambda) {
Marc De Leenheer49087752014-10-23 13:54:09 -0700472 return new LambdaCriterion(lambda, Type.OCH_SIGID);
473 }
474
475 /**
Sho SHIMIZU084c4ca2015-05-04 11:52:51 -0700476 * Creates a match on lambda using the specified value.
477 *
478 * @param lambda lambda
479 * @return match criterion
480 */
481 public static Criterion matchLambda(Lambda lambda) {
Sho SHIMIZUefc2e282015-05-04 15:26:23 -0700482 if (lambda instanceof IndexedLambda) {
483 return new IndexedLambdaCriterion((IndexedLambda) lambda);
484 } else if (lambda instanceof OchSignal) {
Sho SHIMIZU084c4ca2015-05-04 11:52:51 -0700485 return new OchSignalCriterion((OchSignal) lambda);
486 } else {
487 throw new UnsupportedOperationException(String.format("Unsupported type of Lambda: %s", lambda));
488 }
489 }
490
491 /**
Sho SHIMIZUa66cb122014-12-02 18:11:15 -0800492 * Creates a match on optical signal type using the specified value.
Praseed Balakrishnan64369da2014-10-23 15:55:20 -0700493 *
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800494 * @param sigType optical signal type (8 bits unsigned integer)
Praseed Balakrishnan64369da2014-10-23 15:55:20 -0700495 * @return match criterion
Sho SHIMIZU9a2b0812015-06-30 10:02:22 -0700496 * @deprecated in Cardinal Release
Praseed Balakrishnan64369da2014-10-23 15:55:20 -0700497 */
Marc De Leenheerd24420f2015-05-27 09:40:59 -0700498 @Deprecated
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800499 public static Criterion matchOpticalSignalType(short sigType) {
Praseed Balakrishnan2dd5abd2014-11-03 14:56:28 -0800500 return new OpticalSignalTypeCriterion(sigType, Type.OCH_SIGTYPE);
Praseed Balakrishnan64369da2014-10-23 15:55:20 -0700501 }
502
Sho SHIMIZUb5e6de62015-05-04 12:13:44 -0700503 /**
504 * Create a match on OCh (Optical Channel) signal type.
505 *
506 * @param signalType OCh signal type
507 * @return match criterion
508 */
509 public static Criterion matchOchSignalType(OchSignalType signalType) {
510 return new OchSignalTypeCriterion(signalType);
511 }
512
alshabiba3a476d2015-04-10 14:35:38 -0700513 public static Criterion dummy() {
514 return new DummyCriterion();
515 }
516
Praseed Balakrishnan64369da2014-10-23 15:55:20 -0700517 /**
alshabiba3a476d2015-04-10 14:35:38 -0700518 * Dummy Criterion used with @see{FilteringObjective}.
519 */
520 private static class DummyCriterion implements Criterion {
521
522 @Override
523 public Type type() {
524 return Type.DUMMY;
525 }
526 }
tom8bb16062014-09-12 14:47:46 -0700527}