Bump upstreams
[openflowplugin.git] / samples / learning-switch / src / main / java / org / opendaylight / openflowplugin / learningswitch / WakeupOnNode.java
index 32b72cf7d4fd88ff5ec7f68cf766c15f149c19d8..c355cc4f4f4e4ade3ed5016e13f212d02a01237e 100644 (file)
@@ -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<Table> {
-
     private static final Logger LOG = LoggerFactory.getLogger(WakeupOnNode.class);
-    private LearningSwitchHandler learningSwitchHandler;
+
+    private LearningSwitchHandler learningSwitchHandler = null;
 
     @Override
-    public void onDataTreeChanged(@NonNull Collection<DataTreeModification<Table>> modifications) {
+    public void onDataTreeChanged(final Collection<DataTreeModification<Table>> modifications) {
         Uint8 requiredTableId = Uint8.ZERO;
         // TODO add flow
 
-        for (DataTreeModification<Table> 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<Table> 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<Table> {
      *
      * @param learningSwitchHandler the learningSwitchHandler to set
      */
-    public void setLearningSwitchHandler(
-            LearningSwitchHandler learningSwitchHandler) {
+    public void setLearningSwitchHandler(final LearningSwitchHandler learningSwitchHandler) {
         this.learningSwitchHandler = learningSwitchHandler;
     }
 }