From: guillaume.lambert Date: Sun, 17 Mar 2024 20:53:38 +0000 (+0100) Subject: Refactor Networkmodel PortMappingListener X-Git-Tag: 9.0.0~19^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=612bc189751521566f2720adf2a58946786ecf59;p=transportpce.git Refactor Networkmodel PortMappingListener Signed-off-by: guillaume.lambert Change-Id: Id4c08284c6f032258d1cc00920ccb208ccee6e8c --- diff --git a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/listeners/PortMappingListener.java b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/listeners/PortMappingListener.java index 8bc1db81c..5122c39c2 100644 --- a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/listeners/PortMappingListener.java +++ b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/listeners/PortMappingListener.java @@ -30,17 +30,21 @@ public class PortMappingListener implements DataTreeChangeListener { @Override public void onDataTreeChanged(@NonNull List> changes) { for (DataTreeModification change : changes) { - if (change.getRootNode().dataBefore() != null && change.getRootNode().dataAfter() != null) { - Mapping oldMapping = change.getRootNode().dataBefore(); - Mapping newMapping = change.getRootNode().dataAfter(); - if (oldMapping.getPortAdminState().equals(newMapping.getPortAdminState()) - && oldMapping.getPortOperState().equals(newMapping.getPortOperState())) { - return; - } else { - networkModelService.updateOpenRoadmTopologies( - getNodeIdFromMappingDataTreeIdentifier(change.getRootPath()), newMapping); - } + Mapping oldMapping = change.getRootNode().dataBefore(); + if (oldMapping == null) { + continue; } + Mapping newMapping = change.getRootNode().dataAfter(); + if (newMapping == null) { + continue; + } + if (oldMapping.getPortAdminState().equals(newMapping.getPortAdminState()) + && oldMapping.getPortOperState().equals(newMapping.getPortOperState())) { + return; + } + networkModelService.updateOpenRoadmTopologies( + getNodeIdFromMappingDataTreeIdentifier(change.getRootPath()), + newMapping); } }