Adapt TransportPCE code to Sulfur
[transportpce.git] / pce / src / main / java / org / opendaylight / transportpce / pce / constraints / PceConstraintsCalc.java
index aafdae1fb9ffa4c91c17f1a15a9b8a2509041e74..091da934063ed8055628044e82eadee88e4f291d 100644 (file)
@@ -111,25 +111,22 @@ public class PceConstraintsCalc {
     private void readExclude(Exclude exclude, PceConstraints constraints) {
         //TODO: Implement other exclude constraints: fiber-bundle, link-identifier
         // and supporting-service-name
-        List<NodeIdType> nodes = exclude.getNodeId();
-        if (nodes != null) {
+        if (exclude.getNodeId() != null) {
             List<String> elementsToExclude = new ArrayList<>();
-            for (NodeIdType node : nodes) {
+            for (NodeIdType node : exclude.getNodeId()) {
                 elementsToExclude.add(node.getValue());
             }
             constraints.setExcludeSupNodes(elementsToExclude);
         }
-        List<Uint32> srlgs = exclude.getSrlgId();
-        if (srlgs != null) {
+        if (exclude.getSrlgId() != null) {
             List<Long> elementsToExclude = new ArrayList<>();
-            for (Uint32 srlg : srlgs) {
+            for (Uint32 srlg : exclude.getSrlgId()) {
                 elementsToExclude.add(srlg.longValue());
             }
             constraints.setExcludeSRLG(elementsToExclude);
         }
-        List<String> sites = exclude.getSite();
-        if (sites != null) {
-            constraints.setExcludeCLLI(exclude.getSite());
+        if (exclude.getSite() != null) {
+            constraints.setExcludeCLLI(new ArrayList<>(exclude.getSite()));
         }
         if (exclude.getFiberBundle() != null || exclude.getLinkIdentifier() != null
             || exclude.getSupportingServiceName() != null) {
@@ -139,21 +136,18 @@ public class PceConstraintsCalc {
     }
 
     private void readInclude(Include include, PceConstraints constraints) {
-        List<NodeIdType> nodes = include.getNodeId();
-        if (nodes != null) {
-            for (NodeIdType node : nodes) {
+        if (include.getNodeId() != null) {
+            for (NodeIdType node : include.getNodeId()) {
                 constraints.setListToInclude(new ResourcePair(PceConstraints.ResourceType.NODE, node.getValue()));
             }
         }
-        List<Uint32> srlgs = include.getSrlgId();
-        if (srlgs != null) {
-            for (Uint32 srlg : srlgs) {
+        if (include.getSrlgId() != null) {
+            for (Uint32 srlg : include.getSrlgId()) {
                 constraints.setListToInclude(new ResourcePair(PceConstraints.ResourceType.SRLG, srlg.toString()));
             }
         }
-        List<String> sites = include.getSite();
-        if (sites != null) {
-            for (String site : sites) {
+        if (include.getSite() != null) {
+            for (String site : include.getSite()) {
                 constraints.setListToInclude(new ResourcePair(PceConstraints.ResourceType.CLLI, site));
             }
         }