Fix Eclipse warnings in config-manager
[controller.git] / opendaylight / config / config-manager / src / main / java / org / opendaylight / controller / config / manager / impl / osgi / BundleContextBackedModuleFactoriesResolver.java
index 7cb4445328f84355e86ad8590120340354e7df6c..0cbbbab912d3cce521fda7de34837092613b9a47 100644 (file)
@@ -7,6 +7,10 @@
  */
 package org.opendaylight.controller.config.manager.impl.osgi;
 
+import java.util.AbstractMap;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
 import org.opendaylight.controller.config.manager.impl.factoriesresolver.ModuleFactoriesResolver;
 import org.opendaylight.controller.config.spi.ModuleFactory;
 import org.osgi.framework.BundleContext;
@@ -15,22 +19,15 @@ import org.osgi.framework.ServiceReference;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.AbstractMap;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
 /**
  * Retrieves list of currently registered Module Factories using bundlecontext.
  */
-public class BundleContextBackedModuleFactoriesResolver implements
-        ModuleFactoriesResolver {
-    private static final Logger LOGGER = LoggerFactory
-            .getLogger(BundleContextBackedModuleFactoriesResolver.class);
+public class BundleContextBackedModuleFactoriesResolver implements ModuleFactoriesResolver {
+    private static final Logger LOG = LoggerFactory.getLogger(BundleContextBackedModuleFactoriesResolver.class);
     private final BundleContext bundleContext;
 
     public BundleContextBackedModuleFactoriesResolver(
-            BundleContext bundleContext) {
+            final BundleContext bundleContext) {
         this.bundleContext = bundleContext;
     }
 
@@ -38,8 +35,7 @@ public class BundleContextBackedModuleFactoriesResolver implements
     public Map<String, Map.Entry<ModuleFactory, BundleContext>> getAllFactories() {
         Collection<ServiceReference<ModuleFactory>> serviceReferences;
         try {
-            serviceReferences = bundleContext.getServiceReferences(
-                    ModuleFactory.class, null);
+            serviceReferences = bundleContext.getServiceReferences(ModuleFactory.class, null);
         } catch (InvalidSyntaxException e) {
             throw new IllegalStateException(e);
         }
@@ -50,7 +46,7 @@ public class BundleContextBackedModuleFactoriesResolver implements
             // returned by a ServiceFactory does not
             // implement the classes under which it was registered or the
             // ServiceFactory threw an exception.
-            if(factory == null) {
+            if (factory == null) {
                 throw new NullPointerException("ServiceReference of class" + serviceReference.getClass() + "not found.");
             }
 
@@ -62,19 +58,19 @@ public class BundleContextBackedModuleFactoriesResolver implements
             if (serviceReference.getBundle() == null || serviceReference.getBundle().getBundleContext() == null) {
                 throw new NullPointerException("Bundle context of " + factory + " ModuleFactory not found.");
             }
-            LOGGER.debug("Reading factory {} {}", moduleName, factory);
+            LOG.debug("Reading factory {} {}", moduleName, factory);
 
             Map.Entry<ModuleFactory, BundleContext> conflicting = result.get(moduleName);
             if (conflicting != null) {
-                String error = String
-                        .format("Module name is not unique. Found two conflicting factories with same name '%s': '%s' '%s'",
-                                moduleName, conflicting.getKey(), factory);
-                LOGGER.error(error);
+                String error = String.format(
+                    "Module name is not unique. Found two conflicting factories with same name '%s': '%s' '%s'",
+                    moduleName, conflicting.getKey(), factory);
+                LOG.error(error);
                 throw new IllegalArgumentException(error);
-            } else {
-                result.put(moduleName, new AbstractMap.SimpleImmutableEntry<>(factory,
-                        serviceReference.getBundle().getBundleContext()));
             }
+
+            result.put(moduleName, new AbstractMap.SimpleImmutableEntry<>(factory,
+                    serviceReference.getBundle().getBundleContext()));
         }
         return result;
     }