OpticalCircuitIntent is extended to receive path and ochSignal (e.g., from REST optical-rest app).

If the compilation of the OpticalCirsuitIntent trigger the creation of a new OpticalConnectivityIntent
the specified path and ochSignal are used.

Patch 2: Checkstyle

Change-Id: I41aaf6f914738a57634eef0680d73ff64291c696
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalCircuitIntentCompiler.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalCircuitIntentCompiler.java
index 7e873d1..4f8fcbe 100644
--- a/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalCircuitIntentCompiler.java
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/intent/impl/compiler/OpticalCircuitIntentCompiler.java
@@ -250,6 +250,8 @@
             ConnectPoint dstCP = new ConnectPoint(dst.elementId(), ochPorts.getRight().number());
 
             // Create optical connectivity intent
+            // In this case the channel and path optionally specified in this circuit intent
+            // are used to create the connectivity intent
             connectivityIntent = OpticalConnectivityIntent.builder()
                     .appId(appId)
                     // TODO New top-level Intent created and submitted
@@ -261,6 +263,8 @@
                     .priority(OPTICAL_CONNECTIVITY_INTENT_PRIORITY)
                     .signalType(ochPorts.getLeft().signalType())
                     .bidirectional(intent.isBidirectional())
+                    .ochSignal(intent.ochSignal())
+                    .suggestedPath(intent.suggestedPath())
                     .resourceGroup(intent.resourceGroup())
                     .build();
 
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/util/OpticalIntentUtility.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/util/OpticalIntentUtility.java
index 53c6cec..7956f57 100644
--- a/apps/optical-model/src/main/java/org/onosproject/net/optical/util/OpticalIntentUtility.java
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/util/OpticalIntentUtility.java
@@ -38,6 +38,9 @@
 import static org.onosproject.net.optical.device.OpticalDeviceServiceView.opticalView;
 
 import org.slf4j.Logger;
+
+import java.util.Optional;
+
 import static org.slf4j.LoggerFactory.getLogger;
 
 /**
@@ -103,6 +106,8 @@
                         .dst(egress)
                         .signalType(signalType)
                         .bidirectional(bidirectional)
+                        .ochSignal(Optional.ofNullable(signal))
+                        .suggestedPath(Optional.ofNullable(suggestedPath))
                         .build();
             } else if (Type.OTN.equals(srcDevice.type())) {
                 intent = OpticalOduIntent.builder()
@@ -125,8 +130,8 @@
                     .dst(egress)
                     .signalType(signalType)
                     .bidirectional(bidirectional)
-                    .ochSignal(signal)
-                    .suggestedPath(suggestedPath)
+                    .ochSignal(Optional.ofNullable(signal))
+                    .suggestedPath(Optional.ofNullable(suggestedPath))
                     .build();
         } else {
             log.debug("Unable to create optical intent between connect points {} and {}", ingress, egress);
@@ -146,13 +151,13 @@
      * @param bidirectional if this argument is true, the optical link created
      * will be bidirectional, otherwise the link will be unidirectional.
      * @param signal optical signal
-     * @param path suggested path for the intent
+     * @param suggestedPath suggested path for the intent
      *
      * @return created intent
      */
     public static Intent createExplicitOpticalIntent(ConnectPoint ingress, ConnectPoint
             egress, DeviceService deviceService, Key key, ApplicationId appId, boolean
-                                                     bidirectional, OchSignal signal, Path path) {
+                                                     bidirectional, OchSignal signal, Path suggestedPath) {
 
         Intent intent = null;
 
@@ -188,6 +193,8 @@
                         .dst(egress)
                         .signalType(signalType)
                         .bidirectional(bidirectional)
+                        .ochSignal(Optional.ofNullable(signal))
+                        .suggestedPath(Optional.ofNullable(suggestedPath))
                         .build();
             } else if (Type.OTN.equals(srcDevice.type())) {
                 intent = OpticalOduIntent.builder()
@@ -212,8 +219,8 @@
                     .dst(egress)
                     .signalType(signalType)
                     .bidirectional(bidirectional)
-                    .ochSignal(signal)
-                    .suggestedPath(path)
+                    .ochSignal(Optional.ofNullable(signal))
+                    .suggestedPath(Optional.ofNullable(suggestedPath))
                     .build();
         } else {
             log.error("Unable to create explicit optical intent between connect points {} and {}", ingress, egress);
diff --git a/core/api/src/main/java/org/onosproject/net/intent/OpticalCircuitIntent.java b/core/api/src/main/java/org/onosproject/net/intent/OpticalCircuitIntent.java
index 2a29a31..e630b49 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/OpticalCircuitIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/OpticalCircuitIntent.java
@@ -21,8 +21,11 @@
 import org.onosproject.net.CltSignalType;
 import org.onosproject.net.ConnectPoint;
 import org.onosproject.net.ResourceGroup;
+import org.onosproject.net.OchSignal;
+import org.onosproject.net.Path;
 
 import java.util.Collections;
+import java.util.Optional;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
@@ -37,6 +40,9 @@
     private final CltSignalType signalType;
     private final boolean isBidirectional;
 
+    private final Optional<OchSignal> ochSignal;
+    private final Optional<Path> suggestedPath;
+
     /**
      * Creates an optical circuit intent between the specified
      * connection points.
@@ -47,17 +53,28 @@
      * @param dst the destination transponder port
      * @param signalType ODU signal type
      * @param isBidirectional indicate if intent is bidirectional
+     * @param ochSignal optional suggested signal
+     * @param suggestedPath optional suggested path
      * @param priority priority to use for flows from this intent
      * @param resourceGroup resource group for this intent
      */
-    protected OpticalCircuitIntent(ApplicationId appId, Key key, ConnectPoint src, ConnectPoint dst,
-                                   CltSignalType signalType, boolean isBidirectional, int priority,
+    protected OpticalCircuitIntent(ApplicationId appId,
+                                   Key key,
+                                   ConnectPoint src,
+                                   ConnectPoint dst,
+                                   CltSignalType signalType,
+                                   boolean isBidirectional,
+                                   Optional<OchSignal> ochSignal,
+                                   Optional<Path> suggestedPath,
+                                   int priority,
                                    ResourceGroup resourceGroup) {
         super(appId, key, Collections.emptyList(), priority, resourceGroup);
         this.src = checkNotNull(src);
         this.dst = checkNotNull(dst);
         this.signalType = checkNotNull(signalType);
         this.isBidirectional = isBidirectional;
+        this.ochSignal = ochSignal;
+        this.suggestedPath = suggestedPath;
     }
 
     /**
@@ -78,6 +95,8 @@
         private ConnectPoint dst;
         private CltSignalType signalType;
         private boolean isBidirectional;
+        private Optional<OchSignal> ochSignal = Optional.empty();
+        private Optional<Path> suggestedPath = Optional.empty();
 
         @Override
         public Builder appId(ApplicationId appId) {
@@ -144,6 +163,28 @@
         }
 
         /**
+         * Sets the OCh signal of the intent.
+         *
+         * @param ochSignal the lambda
+         * @return this builder
+         */
+        public OpticalCircuitIntent.Builder ochSignal(Optional<OchSignal> ochSignal) {
+            this.ochSignal = ochSignal;
+            return this;
+        }
+
+        /**
+         * Sets the suggestedPath of the intent.
+         *
+         * @param suggestedPath the path
+         * @return this builder
+         */
+        public OpticalCircuitIntent.Builder suggestedPath(Optional<Path> suggestedPath) {
+            this.suggestedPath = suggestedPath;
+            return this;
+        }
+
+        /**
          * Builds an optical circuit intent from the accumulated parameters.
          *
          * @return point to point intent
@@ -157,6 +198,8 @@
                     dst,
                     signalType,
                     isBidirectional,
+                    ochSignal,
+                    suggestedPath,
                     priority,
                     resourceGroup
             );
@@ -172,6 +215,8 @@
         this.dst = null;
         this.signalType = null;
         this.isBidirectional = false;
+        this.ochSignal = null;
+        this.suggestedPath = null;
     }
 
     /**
@@ -210,6 +255,25 @@
         return isBidirectional;
     }
 
+    /**
+     * Returns the OCh signal of the intent.
+     *
+     * @return the lambda
+     */
+
+    public Optional<OchSignal> ochSignal() {
+        return ochSignal;
+    }
+
+    /**
+     * Returns the suggestedPath of the intent.
+     *
+     * @return the suggestedPath
+     */
+    public Optional<Path> suggestedPath() {
+        return suggestedPath;
+    }
+
     @Override
     public String toString() {
         return MoreObjects.toStringHelper(this)
@@ -222,6 +286,8 @@
                 .add("dst", dst)
                 .add("signalType", signalType)
                 .add("isBidirectional", isBidirectional)
+                .add("ochSignal", ochSignal)
+                .add("suggestedPath", suggestedPath)
                 .add("resourceGroup", resourceGroup())
                 .toString();
     }
diff --git a/core/api/src/main/java/org/onosproject/net/intent/OpticalConnectivityIntent.java b/core/api/src/main/java/org/onosproject/net/intent/OpticalConnectivityIntent.java
index 59247e1..f96a0ba 100644
--- a/core/api/src/main/java/org/onosproject/net/intent/OpticalConnectivityIntent.java
+++ b/core/api/src/main/java/org/onosproject/net/intent/OpticalConnectivityIntent.java
@@ -169,8 +169,8 @@
          * @param ochSignal the lambda
          * @return this builder
          */
-        public Builder ochSignal(OchSignal ochSignal) {
-            this.ochSignal = Optional.ofNullable(ochSignal);
+        public Builder ochSignal(Optional<OchSignal> ochSignal) {
+            this.ochSignal = ochSignal;
             return this;
         }
 
@@ -180,8 +180,8 @@
          * @param suggestedPath the path
          * @return this builder
          */
-        public Builder suggestedPath(Path suggestedPath) {
-            this.suggestedPath = Optional.ofNullable(suggestedPath);
+        public Builder suggestedPath(Optional<Path> suggestedPath) {
+            this.suggestedPath = suggestedPath;
             return this;
         }