Make Instructions.modL0Lambda(short) deprecated

Integrate static factory method for indexed lambda and OCh

Change-Id: I80074f7ce2e1703a4ebc7d6f552b52bffc970193
diff --git a/core/api/src/main/java/org/onosproject/net/IndexedLambda.java b/core/api/src/main/java/org/onosproject/net/IndexedLambda.java
index e350b47..5a0077b 100644
--- a/core/api/src/main/java/org/onosproject/net/IndexedLambda.java
+++ b/core/api/src/main/java/org/onosproject/net/IndexedLambda.java
@@ -22,20 +22,29 @@
  */
 public class IndexedLambda implements Lambda {
 
-    private final long lambda;
+    private final long index;
 
     /**
      * Creates an instance representing the wavelength specified by the given index number.
      *
-     * @param lambda index number of wavelength
+     * @param index index number of wavelength
      */
-    IndexedLambda(long lambda) {
-        this.lambda = lambda;
+    IndexedLambda(long index) {
+        this.index = index;
+    }
+
+    /**
+     * Returns the index number of lambda.
+     *
+     * @return the index number of lambda
+     */
+    public long index() {
+        return index;
     }
 
     @Override
     public int hashCode() {
-        return (int) (lambda ^ (lambda >>> 32));
+        return (int) (index ^ (index >>> 32));
     }
 
     @Override
@@ -48,13 +57,13 @@
         }
 
         final IndexedLambda that = (IndexedLambda) obj;
-        return this.lambda == that.lambda;
+        return this.index == that.index;
     }
 
     @Override
     public String toString() {
         return MoreObjects.toStringHelper(this)
-                .add("lambda", lambda)
+                .add("lambda", index)
                 .toString();
     }
 }
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 f9894da..9fdd98a 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,10 +21,13 @@
 import org.onlab.packet.MplsLabel;
 import org.onlab.packet.VlanId;
 import org.onosproject.core.GroupId;
+import org.onosproject.net.IndexedLambda;
+import org.onosproject.net.Lambda;
 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;
+import org.onosproject.net.flow.instructions.L0ModificationInstruction.ModOchSignalInstruction;
 import org.onosproject.net.flow.instructions.L3ModificationInstruction.L3SubType;
 import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPInstruction;
 import org.onosproject.net.flow.instructions.L3ModificationInstruction.ModIPv6FlowLabelInstruction;
@@ -81,7 +84,9 @@
      *
      * @param lambda the lambda to modify to
      * @return a l0 modification
+     * @deprecated in Cardinal Release. Use {@link #modL0Lambda(Lambda)} instead.
      */
+    @Deprecated
     public static L0ModificationInstruction modL0Lambda(short lambda) {
         checkNotNull(lambda, "L0 lambda cannot be null");
         return new ModLambdaInstruction(L0SubType.LAMBDA, lambda);
@@ -93,9 +98,16 @@
      * @param lambda OCh signal
      * @return an L0 modification
      */
-    public static L0ModificationInstruction modL0OchSignal(OchSignal lambda) {
+    public static L0ModificationInstruction modL0Lambda(Lambda lambda) {
         checkNotNull(lambda, "L0 OCh signal cannot be null");
-        return new L0ModificationInstruction.ModOchSignalInstruction(lambda);
+
+        if (lambda instanceof IndexedLambda) {
+            return new ModLambdaInstruction(L0SubType.LAMBDA, (short) ((IndexedLambda) lambda).index());
+        } else if (lambda instanceof OchSignal) {
+            return new ModOchSignalInstruction((OchSignal) lambda);
+        } else {
+            throw new UnsupportedOperationException(String.format("Unsupported type: %s", lambda));
+        }
     }
 
     /**