Add SpectrumFillingRule check in postAlgoValidator
[transportpce.git] / pce / src / main / java / org / opendaylight / transportpce / pce / constraints / PceConstraints.java
index b5e8c7978ce4167d786089120296e5b353f41249..4b63819f857a6961b96b9616158eec1a63404d16 100644 (file)
@@ -9,9 +9,9 @@ package org.opendaylight.transportpce.pce.constraints;
 
 import java.util.ArrayList;
 import java.util.List;
-
-import org.opendaylight.transportpce.pce.networkanalyzer.PceNode;
-import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.routing.constraints.rev171017.RoutingConstraintsSp;
+import java.util.StringJoiner;
+import org.opendaylight.transportpce.pce.networkanalyzer.PceOpticalNode;
+import org.opendaylight.yang.gen.v1.http.org.transportpce.b.c._interface.service.types.rev220118.PceMetric;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -21,43 +21,39 @@ public class PceConstraints {
     private static final Logger LOG = LoggerFactory.getLogger(PceConstraints.class);
 
     // TODO. for now metrics are set into hard structure
-    private RoutingConstraintsSp.PceMetric pceMetrics = RoutingConstraintsSp.PceMetric.HopCount;
-    private Long maxLatency = (long) -1;
+    private PceMetric pceMetrics = PceMetric.HopCount;
+    private Long maxLatency = -1L;
 
-    /////////////// EXCLUDE ///////////////////
+    // Structure related to  EXCLUDE constraints
     // Nodes/CLLI/SRLG lists might consist of two types of elements : (1)from diversity constraints (2)from exclude list
     // e.g.: nodesToExclude - topo-level nodes IDs - comes from diversity constraints
     //     : supNodesToExclude - supporting nodes IDs - comes from exclude list
     // "mapConstraints" class converts diversity elements into correct names
-    private List<String> nodesToExclude = new ArrayList<String>();
-    private List<String> supNodesToExclude = new ArrayList<String>();
+    private List<String> nodesToExclude = new ArrayList<>();
+    private List<String> supNodesToExclude = new ArrayList<>();
 
-    private List<Long> srlgToExclude = new ArrayList<Long>();
-    private List<String> srlgLinksToExclude = new ArrayList<String>();
+    private List<Long> srlgToExclude = new ArrayList<>();
+    private List<String> srlgLinksToExclude = new ArrayList<>();
 
-    private List<String> clliToExclude = new ArrayList<String>();
-    private List<String> clliNodesToExclude = new ArrayList<String>();
-    private List<String> nodesToInclude = new ArrayList<String>();
-    private List<PceNode> pceNodesToInclude = new ArrayList<PceNode>();
+    private List<String> clliToExclude = new ArrayList<>();
+    private List<String> clliNodesToExclude = new ArrayList<>();
 
-    public static final Long CONST_OSNR = 1L;
-    private double maxOSNR = (CONST_OSNR / (Math.pow(10, (24 / 10.0))));
+    ///Structures related to INCLUDE constraints
+    private List<String> nodesToInclude = new ArrayList<>();
+    private List<PceOpticalNode> pceNodesToInclude = new ArrayList<>();
+    private List<ResourcePair> listToInclude = new ArrayList<>();
 
-    /**.
-     * /////////////// INCLUDE CONSTRAINTS.///////////////////
-     */
-    private List<ResourcePair> listToInclude = new ArrayList<ResourcePair>();
-    private List<String> srlgNames = new ArrayList<String>();
+    private List<String> srlgNames = new ArrayList<>();
 
     public enum ResourceType {
         NONE, NODE, SRLG, CLLI;
     }
 
-    public RoutingConstraintsSp.PceMetric getPceMetrics() {
+    public PceMetric getPceMetrics() {
         return pceMetrics;
     }
 
-    public void setPceMetrics(RoutingConstraintsSp.PceMetric pceMetrics) {
+    public void setPceMetrics(PceMetric pceMetrics) {
         this.pceMetrics = pceMetrics;
     }
 
@@ -149,31 +145,42 @@ public class PceConstraints {
         nodesToInclude.addAll(nodes);
     }
 
-    public List<PceNode> getIncludePceNodes() {
+    public List<PceOpticalNode> getIncludePceNodes() {
         LOG.debug("in Pceconstraints getIncludePceNodes size = {}", pceNodesToInclude.size());
         return pceNodesToInclude;
     }
 
-    public void setIncludePceNode(PceNode node) {
-        LOG.info("in Pceconstraints setIncludePceNode new node = {}", node.toString());
+    public void setIncludePceNode(PceOpticalNode node) {
+        LOG.info("in Pceconstraints setIncludePceNode new node = {}", node);
         this.pceNodesToInclude.add(node);
     }
 
-    public Double getMaxOSNR() {
-        LOG.debug("in Pceconstraints getMaxOSNR = {}", maxOSNR);
-        return maxOSNR;
-    }
+    public static class ResourcePair {
 
-    public class ResourcePair {
         public ResourcePair(ResourceType type, String name) {
             super();
             this.type = type;
             this.name = name;
         }
 
-        public ResourceType type = ResourceType.NODE;
+        private ResourceType type = ResourceType.NODE;
+        private String name = "";
+
+        public ResourceType getType() {
+            return type;
+        }
 
-        public String name = "";
+        public String getName() {
+            return name;
+        }
+
+        @Override
+        public String toString() {
+            return new StringJoiner(", ", ResourcePair.class.getSimpleName() + "[", "]")
+                    .add("type=" + type)
+                    .add("name='" + name + "'")
+                    .toString();
+        }
     }
 
     public List<ResourcePair> getListToInclude() {