Making the REST interface accept deferred instructions while adding flows

Change-Id: I6ac2d6a78e11d372f5d72f097554187a564801b1
diff --git a/core/common/src/main/java/org/onosproject/codec/impl/TrafficTreatmentCodec.java b/core/common/src/main/java/org/onosproject/codec/impl/TrafficTreatmentCodec.java
index 6ec5a67..1378c3e 100644
--- a/core/common/src/main/java/org/onosproject/codec/impl/TrafficTreatmentCodec.java
+++ b/core/common/src/main/java/org/onosproject/codec/impl/TrafficTreatmentCodec.java
@@ -34,6 +34,7 @@
  */
 public final class TrafficTreatmentCodec extends JsonCodec<TrafficTreatment> {
     private static final String INSTRUCTIONS = "instructions";
+    private static final String DEFERRED = "deferred";
 
     @Override
     public ObjectNode encode(TrafficTreatment treatment, CodecContext context) {
@@ -78,6 +79,15 @@
                             instructionsCodec.decode(get(instructionsJson, i),
                                     context)));
         }
+
+        JsonNode deferredJson = json.get(DEFERRED);
+        if (deferredJson != null) {
+            IntStream.range(0, deferredJson.size())
+            .forEach(i -> builder.deferred().add(
+                    instructionsCodec.decode(get(deferredJson, i),
+                            context)));
+        }
+
         return builder.build();
     }
 }