remove some useless null checks from portmapping 37/94037/1
authorGilles Thouenon <gilles.thouenon@orange.com>
Tue, 15 Dec 2020 13:52:34 +0000 (14:52 +0100)
committerGuillaume Lambert <guillaume.lambert@orange.com>
Thu, 17 Dec 2020 09:32:44 +0000 (09:32 +0000)
JIRA: TRNSPRTPCE-353
Signed-off-by: guillaume.lambert <guillaume.lambert@orange.com>
Change-Id: Ib4c389d24ae2cf56768d54b5871cbb9f6d8d84bc
(cherry picked from commit d059ad223a3893dcf30f5d7279299606ab906407)

common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion121.java
common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion221.java
common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion710.java

index 6de73f84d0e638b91939c1871188ffee06a5b51b..679dadbb1cc75c4f84cbad3ddd113af3a759215e 100644 (file)
@@ -613,20 +613,16 @@ public class PortMappingVersion121 {
         }
         if (portMapList != null) {
             Map<MappingKey, Mapping> mappingMap = new HashMap<>();
+            // No element in the list below should be null at this stage
             for (Mapping mapping: portMapList) {
-                if (mapping == null) {
-                    continue;
-                }
                 mappingMap.put(mapping.key(), mapping);
             }
             nodesBldr.setMapping(mappingMap);
         }
         if (cp2DegreeList != null) {
             Map<CpToDegreeKey, CpToDegree> cpToDegreeMap = new HashMap<>();
+            // No element in the list below should be null at this stage
             for (CpToDegree cp2Degree: cp2DegreeList) {
-                if (cp2Degree == null) {
-                    continue;
-                }
                 cpToDegreeMap.put(cp2Degree.key(), cp2Degree);
             }
             nodesBldr.setCpToDegree(cpToDegreeMap);
index af9319d56efd7e9bda6acde944513b52da2d3d32..d7b4c1bdd5464576835d7844b88a15b7dfd4035f 100644 (file)
@@ -843,20 +843,16 @@ public class PortMappingVersion221 {
         }
         if (portMapList != null) {
             Map<MappingKey, Mapping> mappingMap = new HashMap<>();
+            // No element in the list below should be null at this stage
             for (Mapping mapping: portMapList) {
-                if (mapping == null) {
-                    continue;
-                }
                 mappingMap.put(mapping.key(), mapping);
             }
             nodesBldr.setMapping(mappingMap);
         }
         if (cp2DegreeList != null) {
             Map<CpToDegreeKey, CpToDegree> cpToDegreeMap = new HashMap<>();
+            // No element in the list below should be null at this stage
             for (CpToDegree cp2Degree: cp2DegreeList) {
-                if (cp2Degree == null) {
-                    continue;
-                }
                 cpToDegreeMap.put(cp2Degree.key(), cp2Degree);
             }
             nodesBldr.setCpToDegree(cpToDegreeMap);
@@ -864,10 +860,8 @@ public class PortMappingVersion221 {
 
         if (splList != null) {
             Map<SwitchingPoolLcpKey,SwitchingPoolLcp> splMap = new HashMap<>();
+            // No element in the list below should be null at this stage
             for (SwitchingPoolLcp spl: splList) {
-                if (spl == null) {
-                    continue;
-                }
                 splMap.put(spl.key(), spl);
             }
             nodesBldr.setSwitchingPoolLcp(splMap);
index b5cdb568acf64816771fa1c665512f93cf965fd4..55a689b4695697f4f56c1c88ef56f8660af6802f 100644 (file)
@@ -864,20 +864,16 @@ public class PortMappingVersion710 {
         }
         if (portMapList != null) {
             Map<MappingKey, Mapping> mappingMap = new HashMap<>();
+            // No element in the list below should be null at this stage
             for (Mapping mapping: portMapList) {
-                if (mapping == null) {
-                    continue;
-                }
                 mappingMap.put(mapping.key(), mapping);
             }
             nodesBldr.setMapping(mappingMap);
         }
         if (cp2DegreeList != null) {
             Map<CpToDegreeKey, CpToDegree> cpToDegreeMap = new HashMap<>();
+            // No element in the list below should be null at this stage
             for (CpToDegree cp2Degree: cp2DegreeList) {
-                if (cp2Degree == null) {
-                    continue;
-                }
                 cpToDegreeMap.put(cp2Degree.key(), cp2Degree);
             }
             nodesBldr.setCpToDegree(cpToDegreeMap);
@@ -885,10 +881,8 @@ public class PortMappingVersion710 {
 
         if (splList != null) {
             Map<SwitchingPoolLcpKey,SwitchingPoolLcp> splMap = new HashMap<>();
+            // No element in the list below should be null at this stage
             for (SwitchingPoolLcp spl: splList) {
-                if (spl == null) {
-                    continue;
-                }
                 splMap.put(spl.key(), spl);
             }
             nodesBldr.setSwitchingPoolLcp(splMap);