Fix checkstyle issues to enforce it
[controller.git] / opendaylight / config / config-manager / src / main / java / org / opendaylight / controller / config / manager / impl / factoriesresolver / HierarchicalConfigMBeanFactoriesHolder.java
index adc8168af5d85b0aee22e717cb59cda7b8939b8f..e07d0d76e1b4f35bf79b4aafd7a0628b01e389ea 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -7,18 +7,16 @@
  */
 package org.opendaylight.controller.config.manager.impl.factoriesresolver;
 
-
-import org.opendaylight.controller.config.spi.ModuleFactory;
-import org.osgi.framework.BundleContext;
-
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
 import java.util.Set;
 import java.util.TreeSet;
+import org.opendaylight.controller.config.api.ModuleFactoryNotFoundException;
+import org.opendaylight.controller.config.spi.ModuleFactory;
+import org.osgi.framework.BundleContext;
 
 /**
  * Hold sorted ConfigMBeanFactories by their module names. Check that module
@@ -33,17 +31,17 @@ public class HierarchicalConfigMBeanFactoriesHolder {
     /**
      * Create instance.
      *
+     * @param factoriesMap map of factories
      * @throws IllegalArgumentException
      *             if unique constraint on module names is violated
      */
     public HierarchicalConfigMBeanFactoriesHolder(
-            Map<String, Map.Entry<ModuleFactory, BundleContext>> factoriesMap) {
-        this.moduleNamesToConfigBeanFactories = Collections
-                .unmodifiableMap(factoriesMap);
-        moduleNames = Collections.unmodifiableSet(new TreeSet<>(
-                moduleNamesToConfigBeanFactories.keySet()));
+            final Map<String, Map.Entry<ModuleFactory, BundleContext>> factoriesMap) {
+        this.moduleNamesToConfigBeanFactories = Collections.unmodifiableMap(factoriesMap);
+        moduleNames = Collections.unmodifiableSet(new TreeSet<>(moduleNamesToConfigBeanFactories.keySet()));
         List<ModuleFactory> factories = new ArrayList<>(this.moduleNamesToConfigBeanFactories.size());
-        Collection<Map.Entry<ModuleFactory, BundleContext>> entryCollection = this.moduleNamesToConfigBeanFactories.values();
+        Collection<Map.Entry<ModuleFactory, BundleContext>> entryCollection = this.moduleNamesToConfigBeanFactories
+                .values();
         for (Map.Entry<ModuleFactory, BundleContext> entry : entryCollection) {
             factories.add(entry.getKey());
         }
@@ -53,14 +51,16 @@ public class HierarchicalConfigMBeanFactoriesHolder {
     /**
      * Get ModuleFactory by their name.
      *
+     * @param moduleName
+     *            module name
+     * @return module factory
      * @throws IllegalArgumentException
      *             if factory is not found
      */
-    public ModuleFactory findByModuleName(String moduleName) {
+    public ModuleFactory findByModuleName(final String moduleName) {
         Map.Entry<ModuleFactory, BundleContext> result = moduleNamesToConfigBeanFactories.get(moduleName);
         if (result == null) {
-            throw new IllegalArgumentException(
-                    "ModuleFactory not found with module name: " + moduleName);
+            throw new ModuleFactoryNotFoundException(moduleName);
         }
         return result.getKey();
     }
@@ -72,8 +72,4 @@ public class HierarchicalConfigMBeanFactoriesHolder {
     public List<ModuleFactory> getModuleFactories() {
         return moduleFactories;
     }
-
-    public Map<String, Entry<ModuleFactory, BundleContext>> getModuleNamesToConfigBeanFactories() {
-        return moduleNamesToConfigBeanFactories;
-    }
 }