Define an Instruction for OchSignal and its static factory method

Resolve ONOS-1873

Change-Id: Ia1d0a97fd820ce7a9b7e2b48ce8d07174bcc1af9
diff --git a/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java b/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java
index 03588b8..f9894da 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/instructions/Instructions.java
@@ -21,6 +21,7 @@
 import org.onlab.packet.MplsLabel;
 import org.onlab.packet.VlanId;
 import org.onosproject.core.GroupId;
+import org.onosproject.net.OchSignal;
 import org.onosproject.net.PortNumber;
 import org.onosproject.net.flow.instructions.L0ModificationInstruction.L0SubType;
 import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModLambdaInstruction;
@@ -87,6 +88,17 @@
     }
 
     /**
+     * Creates an L0 modification with the specified OCh signal.
+     *
+     * @param lambda OCh signal
+     * @return an L0 modification
+     */
+    public static L0ModificationInstruction modL0OchSignal(OchSignal lambda) {
+        checkNotNull(lambda, "L0 OCh signal cannot be null");
+        return new L0ModificationInstruction.ModOchSignalInstruction(lambda);
+    }
+
+    /**
      * Creates a l2 src modification.
      *
      * @param addr the mac address to modify to
diff --git a/core/api/src/main/java/org/onosproject/net/flow/instructions/L0ModificationInstruction.java b/core/api/src/main/java/org/onosproject/net/flow/instructions/L0ModificationInstruction.java
index 18b2566..a6e5903 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/instructions/L0ModificationInstruction.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/instructions/L0ModificationInstruction.java
@@ -15,6 +15,9 @@
  */
 package org.onosproject.net.flow.instructions;
 
+import com.google.common.base.MoreObjects;
+import org.onosproject.net.OchSignal;
+
 import static com.google.common.base.MoreObjects.toStringHelper;
 
 import java.util.Objects;
@@ -28,9 +31,11 @@
         /**
          * Lambda modification.
          */
-        LAMBDA
-
-        //TODO: remaining types
+        LAMBDA,
+        /**
+         * OCh (Optical Channel) modification.
+         */
+        OCH,
     }
 
     public abstract L0SubType subtype();
@@ -86,4 +91,49 @@
             return false;
         }
     }
+
+    /**
+     * Represents an L0 OCh (Optical Channel) modification instruction.
+     */
+    public static final class ModOchSignalInstruction extends L0ModificationInstruction {
+
+        private final OchSignal lambda;
+
+        ModOchSignalInstruction(OchSignal lambda) {
+            this.lambda = lambda;
+        }
+
+        @Override
+        public L0SubType subtype() {
+            return L0SubType.OCH;
+        }
+
+        public OchSignal lambda() {
+            return lambda;
+        }
+
+        @Override
+        public int hashCode() {
+            return Objects.hash(lambda);
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (!(obj instanceof ModOchSignalInstruction)) {
+                return false;
+            }
+            final ModOchSignalInstruction that = (ModOchSignalInstruction) obj;
+            return Objects.equals(this.lambda, that.lambda);
+        }
+
+        @Override
+        public String toString() {
+            return MoreObjects.toStringHelper(this)
+                    .add("lambda", lambda)
+                    .toString();
+        }
+    }
 }