Allowing findPorts() to use all possible OduSignalType values

Change-Id: Ia8431754629345e467a853cda4d4b1a9f3e2a55e
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 a3af158..b463ddc 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
@@ -72,7 +72,9 @@
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Sets;
 
+import java.util.Arrays;
 import java.util.Collections;
+import java.util.Comparator;
 import java.util.Dictionary;
 import java.util.LinkedList;
 import java.util.List;
@@ -424,18 +426,13 @@
 
     private Pair<OchPort, OchPort> findPorts(ConnectPoint src, ConnectPoint dst, CltSignalType signalType) {
         // According to the OpticalCircuitIntent's signalType find OCH ports with available TributarySlots resources
-        switch (signalType) {
-            case CLT_1GBE:
-            case CLT_10GBE:
-                // First search for OCH ports with OduSignalType of ODU2. If not found - search for those with ODU4
-                return findPorts(src, dst, OduSignalType.ODU2)
-                        .orElse(findPorts(src, dst, OduSignalType.ODU4).orElse(null));
-            case CLT_100GBE:
-                return findPorts(src, dst, OduSignalType.ODU4).orElse(null);
-            case CLT_40GBE:
-            default:
-                return null;
-        }
+        return Arrays.asList(OduSignalType.values()).stream()
+                .sorted(Comparator.comparingLong(OduSignalType::bitRate))
+                .filter(oduSignalType -> oduSignalType.bitRate() >= signalType.bitRate())
+                .map(oduSignalType -> findPorts(src, dst, oduSignalType))
+                .flatMap(Tools::stream)
+                .findFirst()
+                .orElse(null);
     }
 
     private Optional<Pair<OchPort, OchPort>> findPorts(ConnectPoint src, ConnectPoint dst,