X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=samples%2Flearning-switch%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Flearningswitch%2FWakeupOnNode.java;h=c355cc4f4f4e4ade3ed5016e13f212d02a01237e;hb=061857a3f18fb8c5d28522eca93527c3cc859a98;hp=32b72cf7d4fd88ff5ec7f68cf766c15f149c19d8;hpb=804680698addeea76349b2fa005da4f8aac43176;p=openflowplugin.git diff --git a/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/WakeupOnNode.java b/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/WakeupOnNode.java index 32b72cf7d4..c355cc4f4f 100644 --- a/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/WakeupOnNode.java +++ b/samples/learning-switch/src/main/java/org/opendaylight/openflowplugin/learningswitch/WakeupOnNode.java @@ -8,38 +8,31 @@ package org.opendaylight.openflowplugin.learningswitch; import java.util.Collection; -import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType; import org.opendaylight.mdsal.binding.api.DataTreeChangeListener; import org.opendaylight.mdsal.binding.api.DataTreeModification; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.Uint8; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class WakeupOnNode implements DataTreeChangeListener { - private static final Logger LOG = LoggerFactory.getLogger(WakeupOnNode.class); - private LearningSwitchHandler learningSwitchHandler; + + private LearningSwitchHandler learningSwitchHandler = null; @Override - public void onDataTreeChanged(@NonNull Collection> modifications) { + public void onDataTreeChanged(final Collection> modifications) { Uint8 requiredTableId = Uint8.ZERO; // TODO add flow - for (DataTreeModification
modification : modifications) { + for (var modification : modifications) { if (modification.getRootNode().getModificationType() == ModificationType.SUBTREE_MODIFIED) { - DataObject table = modification.getRootNode().getDataAfter(); - if (table instanceof Table) { - Table tableSure = (Table) table; + var table = modification.getRootNode().getDataAfter(); + if (table != null) { LOG.trace("table: {}", table); - - if (requiredTableId.equals(tableSure.getId())) { - InstanceIdentifier
tablePath = - modification.getRootPath().getRootIdentifier(); - learningSwitchHandler.onSwitchAppeared(tablePath); + if (requiredTableId.equals(table.getId())) { + learningSwitchHandler.onSwitchAppeared(modification.getRootPath().getRootIdentifier()); } } } @@ -51,8 +44,7 @@ public class WakeupOnNode implements DataTreeChangeListener
{ * * @param learningSwitchHandler the learningSwitchHandler to set */ - public void setLearningSwitchHandler( - LearningSwitchHandler learningSwitchHandler) { + public void setLearningSwitchHandler(final LearningSwitchHandler learningSwitchHandler) { this.learningSwitchHandler = learningSwitchHandler; } }