blob: 96810765ad425f4454ad55e3ac01846388008ff7 [file] [log] [blame]
tom8bb16062014-09-12 14:47:46 -07001package org.onlab.onos.net.flow;
2
alshabib030111e2014-09-15 15:56:42 -07003import static com.google.common.base.Preconditions.checkNotNull;
tom8bb16062014-09-12 14:47:46 -07004
alshabib030111e2014-09-15 15:56:42 -07005import org.onlab.onos.net.PortNumber;
tom8bb16062014-09-12 14:47:46 -07006/**
7 * Factory class for creating various traffic treatment instructions.
8 */
9public final class Instructions {
10
11 // Ban construction
alshabib1d4cace2014-09-13 19:16:26 -070012 private Instructions() {}
tom8bb16062014-09-12 14:47:46 -070013
14 /**
15 * Creates an output instruction using the specified port number. This can
16 * include logical ports such as CONTROLLER, FLOOD, etc.
17 *
18 * @param number port number
19 * @return output instruction
20 */
alshabib030111e2014-09-15 15:56:42 -070021 public static OutputInstruction createOutput(final PortNumber number) {
22 checkNotNull(number, "PortNumber cannot be null");
23 return new OutputInstruction(number);
24 }
alshabib1d4cace2014-09-13 19:16:26 -070025
alshabib030111e2014-09-15 15:56:42 -070026 public static DropInstruction createDrop() {
27 return new DropInstruction();
tom8bb16062014-09-12 14:47:46 -070028 }
29
30 // TODO: add create methods
31
alshabib030111e2014-09-15 15:56:42 -070032 public static final class DropInstruction implements Instruction {
33
34 @Override
35 public Type type() {
36 return Type.DROP;
37 }
38 }
39
40
41 public static final class OutputInstruction implements Instruction {
42
43 private final PortNumber port;
44
45 private OutputInstruction(PortNumber port) {
46 this.port = port;
47 }
48
49 public PortNumber port() {
50 return port;
51 }
52
53 @Override
54 public Type type() {
55 return Type.OUTPUT;
56 }
57
58
59 }
60
tom8bb16062014-09-12 14:47:46 -070061}