From 47fde8545500c326588e17e9be3fc83082f963f0 Mon Sep 17 00:00:00 2001 From: Gilles Thouenon Date: Tue, 15 Dec 2020 14:52:34 +0100 Subject: [PATCH] remove some useless null checks from portmapping JIRA: TRNSPRTPCE-353 Signed-off-by: guillaume.lambert Change-Id: Ib4c389d24ae2cf56768d54b5871cbb9f6d8d84bc (cherry picked from commit d059ad223a3893dcf30f5d7279299606ab906407) --- .../common/mapping/PortMappingVersion121.java | 8 ++------ .../common/mapping/PortMappingVersion221.java | 12 +++--------- .../common/mapping/PortMappingVersion710.java | 12 +++--------- 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion121.java b/common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion121.java index 6de73f84d..679dadbb1 100644 --- a/common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion121.java +++ b/common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion121.java @@ -613,20 +613,16 @@ public class PortMappingVersion121 { } if (portMapList != null) { Map 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 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); diff --git a/common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion221.java b/common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion221.java index af9319d56..d7b4c1bdd 100644 --- a/common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion221.java +++ b/common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion221.java @@ -843,20 +843,16 @@ public class PortMappingVersion221 { } if (portMapList != null) { Map 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 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 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); diff --git a/common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion710.java b/common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion710.java index b5cdb568a..55a689b46 100644 --- a/common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion710.java +++ b/common/src/main/java/org/opendaylight/transportpce/common/mapping/PortMappingVersion710.java @@ -864,20 +864,16 @@ public class PortMappingVersion710 { } if (portMapList != null) { Map 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 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 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); -- 2.36.6