Make TrafficTreatment.Builder.setLambda() deprecated

It is recommended to avoid to use a raw integer value to specify a lambda.

Replace uses of the deprecated method with the alternative

Change-Id: I108f0d15f4503df2a6a75c4f7c77aa0c678ff541
diff --git a/apps/optical/src/main/java/org/onosproject/optical/testapp/LambdaForwarding.java b/apps/optical/src/main/java/org/onosproject/optical/testapp/LambdaForwarding.java
index f35b8be..05d6f12 100644
--- a/apps/optical/src/main/java/org/onosproject/optical/testapp/LambdaForwarding.java
+++ b/apps/optical/src/main/java/org/onosproject/optical/testapp/LambdaForwarding.java
@@ -41,6 +41,7 @@
 import org.onosproject.net.flow.TrafficSelector;
 import org.onosproject.net.flow.TrafficTreatment;
 import org.onosproject.net.flow.criteria.Criteria;
+import org.onosproject.net.flow.instructions.Instructions;
 import org.slf4j.Logger;
 
 /**
@@ -110,7 +111,8 @@
             inport = 10;
             outport = 20;
             sbuilder.matchInPort(PortNumber.portNumber(inport));
-            tbuilder.setOutput(PortNumber.portNumber(outport)).setLambda(lambda);
+            tbuilder.setOutput(PortNumber.portNumber(outport))
+                    .add(Instructions.modL0Lambda(new IndexedLambda(lambda)));
             break;
         case 2:
             inport = 21;
@@ -124,7 +126,8 @@
             outport = 31;
             sbuilder.add(Criteria.matchLambda(new IndexedLambda(lambda))).
                     matchInPort(PortNumber.portNumber(inport));
-            tbuilder.setOutput(PortNumber.portNumber(outport)).setLambda(lambda);
+            tbuilder.setOutput(PortNumber.portNumber(outport))
+                    .add(Instructions.modL0Lambda(new IndexedLambda(lambda)));
             break;
         default:
         }
diff --git a/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java b/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java
index 9562a73..96abbe9 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/DefaultTrafficTreatment.java
@@ -330,6 +330,7 @@
             return add(Instructions.decMplsTtl());
         }
 
+        @Deprecated
         @Override
         public Builder setLambda(short lambda) {
             return add(Instructions.modL0Lambda(new IndexedLambda(lambda)));
diff --git a/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java b/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java
index 9be4b52..3802bf2 100644
--- a/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java
+++ b/core/api/src/main/java/org/onosproject/net/flow/TrafficTreatment.java
@@ -230,7 +230,9 @@
          *
          * @param lambda optical channel ID
          * @return a treatment builder
+         * @deprecated in Drake Release
          */
+        @Deprecated
         Builder setLambda(short lambda);
 
         /**
diff --git a/core/api/src/test/java/org/onosproject/net/flow/DefaultTrafficTreatmentTest.java b/core/api/src/test/java/org/onosproject/net/flow/DefaultTrafficTreatmentTest.java
index fcf6d9c..288f5f2 100644
--- a/core/api/src/test/java/org/onosproject/net/flow/DefaultTrafficTreatmentTest.java
+++ b/core/api/src/test/java/org/onosproject/net/flow/DefaultTrafficTreatmentTest.java
@@ -69,7 +69,7 @@
                 .setEthSrc(MacAddress.BROADCAST)
                 .setIpDst(IpAddress.valueOf("1.1.1.1"))
                 .setIpSrc(IpAddress.valueOf("2.2.2.2"))
-                .setLambda((short) 4)
+                .add(Instructions.modL0Lambda(new IndexedLambda(4)))
                 .setOutput(PortNumber.portNumber(2))
                 .setVlanId(VlanId.vlanId((short) 4))
                 .setVlanPcp((byte) 3);
diff --git a/core/common/src/test/java/org/onosproject/codec/impl/IntentCodecTest.java b/core/common/src/test/java/org/onosproject/codec/impl/IntentCodecTest.java
index 95866bf..cdbd533 100644
--- a/core/common/src/test/java/org/onosproject/codec/impl/IntentCodecTest.java
+++ b/core/common/src/test/java/org/onosproject/codec/impl/IntentCodecTest.java
@@ -32,6 +32,7 @@
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.GridType;
 import org.onosproject.net.HostId;
+import org.onosproject.net.IndexedLambda;
 import org.onosproject.net.Lambda;
 import org.onosproject.net.NetTestTools;
 import org.onosproject.net.OchSignalType;
@@ -41,6 +42,7 @@
 import org.onosproject.net.flow.TrafficSelector;
 import org.onosproject.net.flow.TrafficTreatment;
 import org.onosproject.net.flow.criteria.Criteria;
+import org.onosproject.net.flow.instructions.Instructions;
 import org.onosproject.net.intent.AbstractIntentTest;
 import org.onosproject.net.intent.Constraint;
 import org.onosproject.net.intent.HostToHostIntent;
@@ -151,7 +153,7 @@
                 .matchIPDst(IpPrefix.valueOf("1.2.3.4/24"))
                 .build();
         final TrafficTreatment treatment = DefaultTrafficTreatment.builder()
-                .setLambda((short) 33)
+                .add(Instructions.modL0Lambda(new IndexedLambda(33)))
                 .setMpls(MplsLabel.mplsLabel(44))
                 .setOutput(PortNumber.CONTROLLER)
                 .setEthDst(MacAddress.BROADCAST)
diff --git a/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowEntryBuilder.java b/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowEntryBuilder.java
index 1dfb35d..4605564 100644
--- a/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowEntryBuilder.java
+++ b/providers/openflow/flow/src/main/java/org/onosproject/provider/of/flow/impl/FlowEntryBuilder.java
@@ -37,6 +37,7 @@
 import org.onosproject.net.flow.FlowRule;
 import org.onosproject.net.flow.TrafficSelector;
 import org.onosproject.net.flow.TrafficTreatment;
+import org.onosproject.net.flow.instructions.Instructions;
 import org.onosproject.openflow.controller.Dpid;
 import org.projectfloodlight.openflow.protocol.OFFlowMod;
 import org.projectfloodlight.openflow.protocol.OFFlowRemoved;
@@ -301,7 +302,8 @@
                     if (exp.getExperimenter() == 0x80005A06 ||
                             exp.getExperimenter() == 0x748771) {
                         OFActionCircuit ct = (OFActionCircuit) exp;
-                        builder.setLambda(((OFOxmOchSigidBasic) ct.getField()).getValue().getChannelNumber());
+                        short lambda = ((OFOxmOchSigidBasic) ct.getField()).getValue().getChannelNumber();
+                        builder.add(Instructions.modL0Lambda(Lambda.indexedLambda(lambda)));
                     } else {
                         log.warn("Unsupported OFActionExperimenter {}", exp.getExperimenter());
                     }
diff --git a/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/GroupBucketEntryBuilder.java b/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/GroupBucketEntryBuilder.java
index 272c311..c359f58 100644
--- a/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/GroupBucketEntryBuilder.java
+++ b/providers/openflow/group/src/main/java/org/onosproject/provider/of/group/impl/GroupBucketEntryBuilder.java
@@ -23,9 +23,11 @@
 import org.onlab.packet.VlanId;
 import org.onosproject.core.DefaultGroupId;
 import org.onosproject.core.GroupId;
+import org.onosproject.net.Lambda;
 import org.onosproject.net.PortNumber;
 import org.onosproject.net.flow.DefaultTrafficTreatment;
 import org.onosproject.net.flow.TrafficTreatment;
+import org.onosproject.net.flow.instructions.Instructions;
 import org.onosproject.net.group.DefaultGroupBucket;
 import org.onosproject.net.group.GroupBucket;
 import org.onosproject.net.group.GroupBuckets;
@@ -177,7 +179,8 @@
                     if (exp.getExperimenter() == 0x80005A06 ||
                             exp.getExperimenter() == 0x748771) {
                         OFActionCircuit ct = (OFActionCircuit) exp;
-                        builder.setLambda(((OFOxmOchSigidBasic) ct.getField()).getValue().getChannelNumber());
+                        short lambda = ((OFOxmOchSigidBasic) ct.getField()).getValue().getChannelNumber();
+                        builder.add(Instructions.modL0Lambda(Lambda.indexedLambda(lambda)));
                     } else {
                         log.warn("Unsupported OFActionExperimenter {}", exp.getExperimenter());
                     }