Replace deprecated Futures.addCallback by the newer version
[netconf.git] / netconf / mdsal-netconf-yang-library / src / main / java / org / opendaylight / netconf / mdsal / yang / library / SchemaServiceToMdsalWriter.java
index d8fd148aadc659475782b904d39a9ba616f073b4..d0d383a2bb0dbfe28f2d59ef3cf94f4dc2aa163b 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.netconf.mdsal.yang.library;
 import com.google.common.collect.Lists;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.MoreExecutors;
 import java.util.List;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicInteger;
@@ -39,7 +40,7 @@ import org.slf4j.LoggerFactory;
 
 /**
  * Listens for updates on global schema context, transforms context to ietf-yang-library:modules-state and
- * writes this state to operational data store
+ * writes this state to operational data store.
  */
 // TODO Implement also yang-library-change notfication
 public class SchemaServiceToMdsalWriter implements SchemaContextListener, AutoCloseable {
@@ -66,7 +67,7 @@ public class SchemaServiceToMdsalWriter implements SchemaContextListener, AutoCl
     }
 
     /**
-     * Invoke by blueprint
+     * Invoked by blueprint.
      */
     public void start() {
         schemaService.registerSchemaContextListener(this);
@@ -88,25 +89,28 @@ public class SchemaServiceToMdsalWriter implements SchemaContextListener, AutoCl
             }
 
             @Override
-            public void onFailure(final Throwable t) {
-                LOG.warn("Failed to update modules state", t);
+            public void onFailure(final Throwable throwable) {
+                LOG.warn("Failed to update modules state", throwable);
             }
-        });
+        }, MoreExecutors.directExecutor());
     }
 
     private ModulesState createModuleStateFromModules(final Set<Module> modules) {
         final ModulesStateBuilder modulesStateBuilder = new ModulesStateBuilder();
-        final List<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160409.module.list.Module> moduleList =
+        final List<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160409.module.list
+                .Module> moduleList =
                 Lists.newArrayList();
 
         for (final Module module : modules) {
             moduleList.add(createModuleEntryFromModule(module));
         }
 
-        return modulesStateBuilder.setModule(moduleList).setModuleSetId(String.valueOf(moduleSetId.getAndIncrement())).build();
+        return modulesStateBuilder.setModule(moduleList).setModuleSetId(String.valueOf(moduleSetId.getAndIncrement()))
+                .build();
     }
 
-    private org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160409.module.list.Module createModuleEntryFromModule(final Module module) {
+    private org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.library.rev160409.module.list.Module
+        createModuleEntryFromModule(final Module module) {
         final ModuleBuilder moduleBuilder = new ModuleBuilder();
 
         // TODO Conformance type is always set to Implement value, but it should it really be like this?
@@ -129,6 +133,6 @@ public class SchemaServiceToMdsalWriter implements SchemaContextListener, AutoCl
             submodulesList.add(subModuleEntryBuilder.build());
         }
 
-        return  new SubmodulesBuilder().setSubmodule(submodulesList).build();
+        return new SubmodulesBuilder().setSubmodule(submodulesList).build();
     }
 }