Remove use of org.onosproject.net.resource.ResourceAllocation

The name will conflict with the primitive in new resource API during
future refactoring. This commit is to avoid the conflict.

Change-Id: I47928ba6fa56c00aea7c0f85d7be8593b4862cba
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalConnectivityIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalConnectivityIntentCompiler.java
index 05a20f9..60db797 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalConnectivityIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalConnectivityIntentCompiler.java
@@ -40,7 +40,6 @@
 import org.onosproject.net.intent.OpticalConnectivityIntent;
 import org.onosproject.net.intent.OpticalPathIntent;
 import org.onosproject.net.intent.impl.IntentCompilationException;
-import org.onosproject.net.resource.ResourceAllocation;
 import org.onosproject.net.resource.ResourceType;
 import org.onosproject.net.resource.device.DeviceResourceService;
 import org.onosproject.net.resource.link.DefaultLinkResourceRequest;
@@ -57,6 +56,7 @@
 
 import java.util.List;
 import java.util.Set;
+import java.util.stream.Collectors;
 
 import static com.google.common.base.Preconditions.checkArgument;
 
@@ -174,15 +174,12 @@
      * @return lambda allocated to the given path
      */
     private LambdaResourceAllocation getWavelength(Path path, LinkResourceAllocations linkAllocs) {
-        for (Link link : path.links()) {
-            for (ResourceAllocation alloc : linkAllocs.getResourceAllocation(link)) {
-                if (alloc.type() == ResourceType.LAMBDA) {
-                    return (LambdaResourceAllocation) alloc;
-                }
-            }
-        }
-
-        return null;
+        return path.links().stream()
+                .flatMap(x -> linkAllocs.getResourceAllocation(x).stream())
+                .filter(x -> x.type() == ResourceType.LAMBDA)
+                .findFirst()
+                .map(x -> (LambdaResourceAllocation) x)
+                .orElse(null);
     }
 
     /**
@@ -215,23 +212,23 @@
             return false;
         }
 
-        LambdaResource lambda = null;
+        List<LambdaResource> lambdas = path.links().stream()
+                .flatMap(x -> allocations.getResourceAllocation(x).stream())
+                .filter(x -> x.type() == ResourceType.LAMBDA)
+                .map(x -> ((LambdaResourceAllocation) x).lambda())
+                .collect(Collectors.toList());
 
-        for (Link link : path.links()) {
-            for (ResourceAllocation alloc : allocations.getResourceAllocation(link)) {
-                if (alloc.type() == ResourceType.LAMBDA) {
-                    LambdaResource nextLambda = ((LambdaResourceAllocation) alloc).lambda();
-                    if (nextLambda == null) {
-                        return false;
-                    }
-                    if (lambda == null) {
-                        lambda = nextLambda;
-                        continue;
-                    }
-                    if (!lambda.equals(nextLambda)) {
-                        return false;
-                    }
-                }
+        LambdaResource lambda = null;
+        for (LambdaResource nextLambda: lambdas) {
+            if (nextLambda == null) {
+                return false;
+            }
+            if (lambda == null) {
+                lambda = nextLambda;
+                continue;
+            }
+            if (!lambda.equals(nextLambda)) {
+                return false;
             }
         }