Issue fix for config subsystem 99/11999/1
authorFilip Tehlar <ftehlar@cisco.com>
Thu, 16 Oct 2014 10:42:12 +0000 (12:42 +0200)
committerFilip Tehlar <ftehlar@cisco.com>
Thu, 16 Oct 2014 10:42:12 +0000 (12:42 +0200)
Change-Id: I73d02158accb65c92dabc76eb8b353b052ac2d05
Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
59 files changed:
opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/IdentityAttributeRef.java
opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/ObjectNameUtil.java
opendaylight/config/config-api/src/main/java/org/opendaylight/controller/config/api/jmx/constants/ConfigRegistryConstants.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ConfigRegistryImpl.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ConfigTransactionControllerImpl.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/DeadlockMonitor.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/ServiceReferenceRegistryImpl.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dependencyresolver/DependencyResolverImpl.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dependencyresolver/DependencyResolverManager.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dependencyresolver/DestroyedModule.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dynamicmbean/AbstractDynamicWrapper.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dynamicmbean/AnnotationsHelper.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dynamicmbean/AttributeHolder.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dynamicmbean/DynamicReadableWrapper.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/dynamicmbean/DynamicWritableWrapper.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/jmx/InternalJMXRegistrator.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/jmx/ModuleJMXRegistrator.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/BeanToOsgiServiceManager.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/BlankTransactionServiceTracker.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/BundleContextBackedModuleFactoriesResolver.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ModuleFactoryBundleTracker.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/ModuleInfoBundleTracker.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/util/InterfacesHelper.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/util/LookupBeansUtil.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/util/ModuleQNameUtil.java
opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/util/OsgiRegistrationUtil.java
opendaylight/config/config-persister-feature-adapter/src/main/java/org/opendaylight/controller/configpusherfeature/internal/AbstractFeatureWrapper.java
opendaylight/config/config-persister-feature-adapter/src/main/java/org/opendaylight/controller/configpusherfeature/internal/ChildAwareFeatureWrapper.java
opendaylight/config/config-persister-feature-adapter/src/main/java/org/opendaylight/controller/configpusherfeature/internal/ConfigFeaturesListener.java
opendaylight/config/config-persister-feature-adapter/src/main/java/org/opendaylight/controller/configpusherfeature/internal/ConfigPusherCustomizer.java
opendaylight/config/config-persister-feature-adapter/src/main/java/org/opendaylight/controller/configpusherfeature/internal/ConfigPushingRunnable.java
opendaylight/config/config-persister-feature-adapter/src/main/java/org/opendaylight/controller/configpusherfeature/internal/FeatureConfigPusher.java
opendaylight/config/config-persister-file-xml-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/file/xml/XmlFileStorageAdapter.java
opendaylight/config/config-persister-file-xml-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/file/xml/model/ConfigSnapshot.java
opendaylight/config/config-persister-file-xml-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/file/xml/model/StringTrimAdapter.java
opendaylight/config/config-util/src/main/java/org/opendaylight/controller/config/util/ConfigRegistryJMXClient.java
opendaylight/config/config-util/src/main/java/org/opendaylight/controller/config/util/ConfigTransactionJMXClient.java
opendaylight/config/logback-config/src/main/java/org/opendaylight/controller/config/yang/logback/config/ContextSetterImpl.java
opendaylight/config/logback-config/src/main/java/org/opendaylight/controller/config/yang/logback/config/LogbackModuleFactory.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/CodeWriter.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/JMXGenerator.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/AbstractFactoryTemplate.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/RuntimeRegistratorFtlTemplate.java
opendaylight/config/yang-jmx-generator-plugin/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/ftl/TemplateFactory.java
opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/ConfigConstants.java
opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/ModuleMXBeanEntryBuilder.java
opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/ModuleUtil.java
opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/PackageTranslator.java
opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/RuntimeBeanEntry.java
opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/ServiceInterfaceEntry.java
opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/TypeProviderWrapper.java
opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/AbstractAttribute.java
opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/AbstractDependencyAttribute.java
opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/JavaAttribute.java
opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/ListAttribute.java
opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/SimpleTypeResolver.java
opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/TOAttribute.java
opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/attribute/Util.java
opendaylight/config/yang-jmx-generator/src/main/java/org/opendaylight/controller/config/yangjmxgenerator/plugin/util/FullyQualifiedNameHelper.java

index 5ad6e0da8d2bf8a29d8d403783e378c5ab950346..48aa6ae64667f502a39cb636ae319ef7617db478 100644 (file)
@@ -39,7 +39,7 @@ public final class IdentityAttributeRef {
 
     @Override
     public String toString() {
-        final StringBuffer sb = new StringBuffer("IdentityAttributeRef{");
+        final StringBuilder sb = new StringBuilder("IdentityAttributeRef{");
         sb.append("qNameOfIdentity='").append(qNameOfIdentity).append('\'');
         sb.append('}');
         return sb.toString();
index abb9f1ae9bf4d448c78bc795a74f0076b68de745..c23a0cbf69850f364113a93579e79d9dc952ae5c 100644 (file)
@@ -29,6 +29,8 @@ import java.util.Set;
  */
 @ThreadSafe
 public class ObjectNameUtil {
+    private ObjectNameUtil() {
+    }
 
     public static final String ON_DOMAIN = ConfigRegistryConstants.ON_DOMAIN;
     public static final String MODULE_FACTORY_NAME_KEY = "moduleFactoryName";
@@ -270,7 +272,7 @@ public class ObjectNameUtil {
     }
 
     public static Map<String, String> getAdditionalProperties(ObjectName on) {
-        Hashtable<String, String> keyPropertyList = on.getKeyPropertyList();
+        Map<String, String> keyPropertyList = on.getKeyPropertyList();
         Map<String, String> result = new HashMap<>();
         for (Entry<String, String> entry : keyPropertyList.entrySet()) {
             result.put(entry.getKey(), entry.getValue());
@@ -304,8 +306,8 @@ public class ObjectNameUtil {
 
     public static ObjectName createModulePattern(String moduleName,
                                                  String instanceName) {
-        moduleName = moduleName == null ? ON_WILDCARD : moduleName;
-        instanceName = instanceName == null ? ON_WILDCARD : instanceName;
+        String finalModuleName = moduleName == null ? ON_WILDCARD : moduleName;
+        String finalInstanceName = instanceName == null ? ON_WILDCARD : instanceName;
 
         // do not return object names containing transaction name
         ObjectName namePattern = ObjectNameUtil
@@ -313,34 +315,34 @@ public class ObjectNameUtil {
                         + ObjectNameUtil.TYPE_KEY + "="
                         + ObjectNameUtil.TYPE_MODULE + ","
                         + ObjectNameUtil.MODULE_FACTORY_NAME_KEY + "="
-                        + moduleName + "," + ""
-                        + ObjectNameUtil.INSTANCE_NAME_KEY + "=" + instanceName);
+                        + finalModuleName + "," + ""
+                        + ObjectNameUtil.INSTANCE_NAME_KEY + "=" + finalInstanceName);
         return namePattern;
     }
 
     public static ObjectName createModulePattern(String ifcName,
                                                  String instanceName, String transactionName) {
-        ifcName = ifcName == null ? ON_WILDCARD : ifcName;
-        instanceName = instanceName == null ? ON_WILDCARD : instanceName;
-        transactionName = transactionName == null ? ON_WILDCARD : transactionName;
+        String finalIfcName = ifcName == null ? ON_WILDCARD : ifcName;
+        String finalInstanceName = instanceName == null ? ON_WILDCARD : instanceName;
+        String finalTransactionName = transactionName == null ? ON_WILDCARD : transactionName;
 
         return ObjectNameUtil.createON(ObjectNameUtil.ON_DOMAIN
                 + ":type=Module," + ObjectNameUtil.MODULE_FACTORY_NAME_KEY
-                + "=" + ifcName + "," + ObjectNameUtil.INSTANCE_NAME_KEY + "="
-                + instanceName + "," + ObjectNameUtil.TRANSACTION_NAME_KEY
-                + "=" + transactionName);
+                + "=" + finalIfcName + "," + ObjectNameUtil.INSTANCE_NAME_KEY + "="
+                + finalInstanceName + "," + ObjectNameUtil.TRANSACTION_NAME_KEY
+                + "=" + finalTransactionName);
     }
 
     public static ObjectName createRuntimeBeanPattern(String moduleName,
                                                       String instanceName) {
-        moduleName = moduleName == null ? ON_WILDCARD : moduleName;
-        instanceName = instanceName == null ? ON_WILDCARD : instanceName;
+        String finalModuleName = moduleName == null ? ON_WILDCARD : moduleName;
+        String finalInstanceName = instanceName == null ? ON_WILDCARD : instanceName;
 
         return ObjectNameUtil.createON(ObjectNameUtil.ON_DOMAIN + ":"
                 + ObjectNameUtil.TYPE_KEY + "="
                 + ObjectNameUtil.TYPE_RUNTIME_BEAN + ","
-                + ObjectNameUtil.MODULE_FACTORY_NAME_KEY + "=" + moduleName
-                + "," + ObjectNameUtil.INSTANCE_NAME_KEY + "=" + instanceName
+                + ObjectNameUtil.MODULE_FACTORY_NAME_KEY + "=" + finalModuleName
+                + "," + ObjectNameUtil.INSTANCE_NAME_KEY + "=" + finalInstanceName
                 + ",*");
 
     }
index 1d9563bf4e1d7733b170cdd6c092f473a8baae20..bdb6f0e344e97472cb5d5e3e241783776d51066d 100644 (file)
@@ -12,6 +12,9 @@ import javax.management.ObjectName;
 
 public class ConfigRegistryConstants {
 
+    private ConfigRegistryConstants() {
+    }
+
     public static final String TYPE_CONFIG_REGISTRY = "ConfigRegistry";
 
     public static final String ON_DOMAIN = "org.opendaylight.controller";
index b7cdf9475753e92f34fcbeae620a95025c9941a9..605223ae227cfa2b6e22e7861e63df325b17686b 100644 (file)
@@ -60,7 +60,7 @@ import java.util.Set;
  */
 @ThreadSafe
 public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBean {
-    private static final Logger logger = LoggerFactory.getLogger(ConfigRegistryImpl.class);
+    private static final Logger LOGGER = LoggerFactory.getLogger(ConfigRegistryImpl.class);
 
     private final ModuleFactoriesResolver resolver;
     private final MBeanServer configMBeanServer;
@@ -166,7 +166,7 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe
         for (ModuleInternalInfo moduleInternalInfo : currentConfig.getEntries()) {
             String name = moduleInternalInfo.getModuleFactory().getImplementationName();
             if (allCurrentFactories.containsKey(name) == false) {
-                logger.trace("Factory {} not found in SR, using reference from previous commit", name);
+                LOGGER.trace("Factory {} not found in SR, using reference from previous commit", name);
                 allCurrentFactories.put(name,
                         Maps.immutableEntry(moduleInternalInfo.getModuleFactory(), moduleInternalInfo.getBundleContext()));
             }
@@ -202,7 +202,7 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe
             throws ConflictingVersionException, ValidationException {
         final String transactionName = ObjectNameUtil
                 .getTransactionName(transactionControllerON);
-        logger.trace("About to commit {}. Current parentVersion: {}, versionCounter {}", transactionName, version, versionCounter);
+        LOGGER.trace("About to commit {}. Current parentVersion: {}, versionCounter {}", transactionName, version, versionCounter);
 
         // find ConfigTransactionController
         Map<String, Entry<ConfigTransactionControllerInternal, ConfigTransactionLookupRegistry>> transactions = transactionsHolder.getCurrentTransactions();
@@ -230,7 +230,7 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe
         } catch (Error | RuntimeException t) { // some libs throw Errors: e.g.
             // javax.xml.ws.spi.FactoryFinder$ConfigurationError
             isHealthy = false;
-            logger.error("Configuration Transaction failed on 2PC, server is unhealthy", t);
+            LOGGER.error("Configuration Transaction failed on 2PC, server is unhealthy", t);
             if (t instanceof RuntimeException) {
                 throw (RuntimeException) t;
             } else {
@@ -292,7 +292,7 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe
 
         int orderingIdx = 0;
         for (ModuleIdentifier moduleIdentifier : orderedModuleIdentifiers) {
-            logger.trace("Registering {}", moduleIdentifier);
+            LOGGER.trace("Registering {}", moduleIdentifier);
             ModuleInternalTransactionalInfo entry = commitInfo.getCommitted()
                     .get(moduleIdentifier);
             if (entry == null) {
@@ -427,7 +427,7 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe
                 configTransactionControllerEntry.getValue().close();
                 configTransactionController.abortConfig();
             } catch (RuntimeException e) {
-                logger.warn("Ignoring exception while aborting {}",
+                LOGGER.warn("Ignoring exception while aborting {}",
                         configTransactionController, e);
             }
         }
@@ -524,14 +524,10 @@ public class ConfigRegistryImpl implements AutoCloseable, ConfigRegistryImplMXBe
     @Override
     public Set<ObjectName> lookupRuntimeBeans(String moduleName,
                                               String instanceName) {
-        if (moduleName == null) {
-            moduleName = "*";
-        }
-        if (instanceName == null) {
-            instanceName = "*";
-        }
+        String finalModuleName = moduleName == null ? "*" : moduleName;
+        String finalInstanceName = instanceName == null ? "*" : instanceName;
         ObjectName namePattern = ObjectNameUtil.createRuntimeBeanPattern(
-                moduleName, instanceName);
+                finalModuleName, finalInstanceName);
         return baseJMXRegistrator.queryNames(namePattern, null);
     }
 
@@ -609,7 +605,7 @@ class ConfigHolder {
      * Service Registry.
      */
     public void addAll(Collection<ModuleInternalInfo> configInfos) {
-        if (currentConfig.size() > 0) {
+        if (!currentConfig.isEmpty()) {
             throw new IllegalStateException(
                     "Error - some config entries were not removed: "
                             + currentConfig);
index 39eef8741ba840309b8293e19f14af437652e82e..a58f7a05c65ae9a1f31a407e53c6f54d028e3200 100644 (file)
@@ -53,7 +53,7 @@ class ConfigTransactionControllerImpl implements
         ConfigTransactionControllerInternal,
         ConfigTransactionControllerImplMXBean,
         Identifiable<TransactionIdentifier> {
-    private static final Logger logger = LoggerFactory.getLogger(ConfigTransactionControllerImpl.class);
+    private static final Logger LOGGER = LoggerFactory.getLogger(ConfigTransactionControllerImpl.class);
 
     private final ConfigTransactionLookupRegistry txLookupRegistry;
     private final ObjectName controllerON;
@@ -226,7 +226,7 @@ class ConfigTransactionControllerImpl implements
             boolean isDefaultBean, BundleContext bundleContext)
             throws InstanceAlreadyExistsException {
 
-        logger.debug("Adding module {} to transaction {}", moduleIdentifier, this);
+        LOGGER.debug("Adding module {} to transaction {}", moduleIdentifier, this);
         if (moduleIdentifier.equals(module.getIdentifier()) == false) {
             throw new IllegalStateException("Incorrect name reported by module. Expected "
                     + moduleIdentifier + ", got " + module.getIdentifier());
@@ -271,15 +271,13 @@ class ConfigTransactionControllerImpl implements
     }
 
     private synchronized void destroyModule(ModuleIdentifier moduleIdentifier) {
-        logger.debug("Destroying module {} in transaction {}", moduleIdentifier, this);
+        LOGGER.debug("Destroying module {} in transaction {}", moduleIdentifier, this);
         transactionStatus.checkNotAborted();
 
         ModuleInternalTransactionalInfo found = dependencyResolverManager.findModuleInternalTransactionalInfo(moduleIdentifier);
-        if (blankTransaction == false) {
-
-            if (found.isDefaultBean()) {
-                logger.warn("Warning: removing default bean. This will be forbidden in next version of config-subsystem");
-            }
+        if (blankTransaction == false &&
+                found.isDefaultBean()) {
+            LOGGER.warn("Warning: removing default bean. This will be forbidden in next version of config-subsystem");
         }
         // first remove refNames, it checks for objectname existence
 
@@ -287,7 +285,7 @@ class ConfigTransactionControllerImpl implements
             writableSRRegistry.removeServiceReferences(
                     ObjectNameUtil.createTransactionModuleON(getTransactionName(), moduleIdentifier));
         } catch (InstanceNotFoundException e) {
-            logger.error("Possible code error: cannot find {} in {}", moduleIdentifier, writableSRRegistry);
+            LOGGER.error("Possible code error: cannot find {} in {}", moduleIdentifier, writableSRRegistry);
             throw new IllegalStateException("Possible code error: cannot find " + moduleIdentifier, e);
         }
 
@@ -313,15 +311,15 @@ class ConfigTransactionControllerImpl implements
         }
         configBeanModificationDisabled.set(true);
         try {
-            validate_noLocks();
+            validateNoLocks();
         } finally {
             configBeanModificationDisabled.set(false);
         }
     }
 
-    private void validate_noLocks() throws ValidationException {
+    private void validateNoLocks() throws ValidationException {
         transactionStatus.checkNotAborted();
-        logger.trace("Validating transaction {}", getTransactionIdentifier());
+        LOGGER.trace("Validating transaction {}", getTransactionIdentifier());
         // call validate()
         List<ValidationException> collectedExceptions = new ArrayList<>();
         for (Entry<ModuleIdentifier, Module> entry : dependencyResolverManager
@@ -331,17 +329,17 @@ class ConfigTransactionControllerImpl implements
             try {
                 module.validate();
             } catch (Exception e) {
-                logger.warn("Validation exception in {}", getTransactionName(),
+                LOGGER.warn("Validation exception in {}", getTransactionName(),
                         e);
                 collectedExceptions.add(ValidationException
                         .createForSingleException(name, e));
             }
         }
-        if (collectedExceptions.size() > 0) {
+        if (!collectedExceptions.isEmpty()) {
             throw ValidationException
                     .createFromCollectedValidationExceptions(collectedExceptions);
         }
-        logger.trace("Validated transaction {}", getTransactionIdentifier());
+        LOGGER.trace("Validated transaction {}", getTransactionIdentifier());
     }
 
     /**
@@ -358,9 +356,9 @@ class ConfigTransactionControllerImpl implements
         transactionStatus.checkNotCommitStarted();
         configBeanModificationDisabled.set(true);
         try {
-            validate_noLocks();
+            validateNoLocks();
         } catch (ValidationException e) {
-            logger.trace("Commit failed on validation");
+            LOGGER.trace("Commit failed on validation");
             configBeanModificationDisabled.set(false); // recoverable error
             throw e;
         }
@@ -383,7 +381,7 @@ class ConfigTransactionControllerImpl implements
                             + "to obtain a lock");
         }
 
-        logger.trace("Committing transaction {}", getTransactionIdentifier());
+        LOGGER.trace("Committing transaction {}", getTransactionIdentifier());
 
         // call getInstance()
         for (Entry<ModuleIdentifier, Module> entry : dependencyResolverManager
@@ -391,12 +389,12 @@ class ConfigTransactionControllerImpl implements
             Module module = entry.getValue();
             ModuleIdentifier name = entry.getKey();
             try {
-                logger.debug("About to commit {} in transaction {}",
+                LOGGER.debug("About to commit {} in transaction {}",
                         name, getTransactionIdentifier());
                 AutoCloseable instance = module.getInstance();
                 checkNotNull(instance, "Instance is null:{} in transaction {}", name, getTransactionIdentifier());
             } catch (Exception e) {
-                logger.error("Commit failed on {} in transaction {}", name,
+                LOGGER.error("Commit failed on {} in transaction {}", name,
                         getTransactionIdentifier(), e);
                 internalAbort();
                 throw new IllegalStateException(
@@ -407,7 +405,7 @@ class ConfigTransactionControllerImpl implements
 
         // count dependency order
 
-        logger.trace("Committed configuration {}", getTransactionIdentifier());
+        LOGGER.trace("Committed configuration {}", getTransactionIdentifier());
         transactionStatus.setCommitted();
 
         return dependencyResolverManager.getSortedModuleIdentifiers();
@@ -421,7 +419,7 @@ class ConfigTransactionControllerImpl implements
     }
 
     private void internalAbort() {
-        logger.trace("Aborting {}", this);
+        LOGGER.trace("Aborting {}", this);
         transactionStatus.setAborted();
         close();
     }
index d34a739703e8f8eba7d60a90ca6fa713a301f802..b59b48e5a98eafb05d92622e1b1d9363c81f91a0 100644 (file)
@@ -11,7 +11,7 @@ import java.util.LinkedList;
 import java.util.concurrent.TimeUnit;
 
 public class DeadlockMonitor implements AutoCloseable {
-    private static final Logger logger = LoggerFactory.getLogger(DeadlockMonitorRunnable.class);
+    private static final Logger LOGGER = LoggerFactory.getLogger(DeadlockMonitorRunnable.class);
 
     private static final long WARN_AFTER_MILLIS = 5000;
 
@@ -43,7 +43,7 @@ public class DeadlockMonitor implements AutoCloseable {
             moduleIdentifierWithNanosStack.push(current);
             top = current;
         }
-        logger.trace("setCurrentlyInstantiatedModule {}, top {}", currentlyInstantiatedModule, top);
+        LOGGER.trace("setCurrentlyInstantiatedModule {}, top {}", currentlyInstantiatedModule, top);
     }
 
     public boolean isAlive() {
@@ -78,7 +78,7 @@ public class DeadlockMonitor implements AutoCloseable {
                     // is the getInstance() running longer than WARN_AFTER_MILLIS ?
                     long runningTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - copy.nanoTime);
                     if (runningTime > WARN_AFTER_MILLIS) {
-                        logger.warn("{} did not finish after {} ms", copy.moduleIdentifier, runningTime);
+                        LOGGER.warn("{} did not finish after {} ms", copy.moduleIdentifier, runningTime);
                     }
                 }
                 try {
@@ -87,7 +87,7 @@ public class DeadlockMonitor implements AutoCloseable {
                     interrupt();
                 }
             }
-            logger.trace("Exiting {}", this);
+            LOGGER.trace("Exiting {}", this);
         }
 
         @Override
@@ -122,14 +122,21 @@ public class DeadlockMonitor implements AutoCloseable {
 
         @Override
         public boolean equals(Object o) {
-            if (this == o) return true;
-            if (o == null || getClass() != o.getClass()) return false;
+            if (this == o) {
+                return true;
+            }
+            if (o == null || getClass() != o.getClass()) {
+                return false;
+            }
 
             ModuleIdentifierWithNanos that = (ModuleIdentifierWithNanos) o;
 
-            if (nanoTime != that.nanoTime) return false;
-            if (moduleIdentifier != null ? !moduleIdentifier.equals(that.moduleIdentifier) : that.moduleIdentifier != null)
+            if (nanoTime != that.nanoTime) {
                 return false;
+            }
+            if (moduleIdentifier != null ? !moduleIdentifier.equals(that.moduleIdentifier) : that.moduleIdentifier != null) {
+                return false;
+            }
 
             return true;
         }
index 52bb3f5ed1df99a678e9ad44357cef6eadc4b3cf..0f881e95add37a0ac925ff1b835ba2813cc6c4b0 100644 (file)
@@ -38,7 +38,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceReadableRegistry, SearchableServiceReferenceWritableRegistry {
-    private static final Logger logger = LoggerFactory.getLogger(ServiceReferenceRegistryImpl.class);
+    private static final Logger LOGGER = LoggerFactory.getLogger(ServiceReferenceRegistryImpl.class);
 
     private final Map<String, ModuleFactory> factories;
     private final Map<String, Set<String>> factoryNamesToQNames;
@@ -176,7 +176,7 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
                 boolean skipChecks = true;
                 newRegistry.saveServiceReference(refNameEntry.getKey(), currentImplementation, skipChecks);
             } catch (InstanceNotFoundException e) {
-                logger.error("Cannot save service reference({}, {})", refNameEntry.getKey(), currentImplementation);
+                LOGGER.error("Cannot save service reference({}, {})", refNameEntry.getKey(), currentImplementation);
                 throw new IllegalStateException("Possible code error", e);
             }
         }
@@ -201,22 +201,22 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
 
         Map<String, Set<String /* QName */>> modifiableFactoryNamesToQNames = new HashMap<>();
         Set<ServiceInterfaceAnnotation> allAnnotations = new HashSet<>();
-        Set<String /* qName */> allQNames = new HashSet<>();
+        Set<String /* qName */> allQNameSet = new HashSet<>();
 
 
         for (Entry<String, ModuleFactory> entry : factories.entrySet()) {
             if (entry.getKey().equals(entry.getValue().getImplementationName()) == false) {
-                logger.error("Possible error in code: Mismatch between supplied and actual name of {}", entry);
+                LOGGER.error("Possible error in code: Mismatch between supplied and actual name of {}", entry);
                 throw new IllegalArgumentException("Possible error in code: Mismatch between supplied and actual name of " + entry);
             }
             Set<ServiceInterfaceAnnotation> siAnnotations = InterfacesHelper.getServiceInterfaceAnnotations(entry.getValue());
             Set<String> qNames = InterfacesHelper.getQNames(siAnnotations);
             allAnnotations.addAll(siAnnotations);
-            allQNames.addAll(qNames);
+            allQNameSet.addAll(qNames);
             modifiableFactoryNamesToQNames.put(entry.getKey(), Collections.unmodifiableSet(qNames));
         }
         this.factoryNamesToQNames = Collections.unmodifiableMap(modifiableFactoryNamesToQNames);
-        this.allQNames = Collections.unmodifiableSet(allQNames);
+        this.allQNames = Collections.unmodifiableSet(allQNameSet);
         // fill namespacesToAnnotations
         Map<String /* namespace */, Map<String /* localName */, ServiceInterfaceAnnotation>> modifiableNamespacesToAnnotations =
                 new HashMap<>();
@@ -228,7 +228,7 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
                 modifiableNamespacesToAnnotations.put(sia.namespace(), ofNamespace);
             }
             if (ofNamespace.containsKey(sia.localName())) {
-                logger.error("Cannot construct namespacesToAnnotations map, conflict between local names in {}, offending local name: {}, map so far {}",
+                LOGGER.error("Cannot construct namespacesToAnnotations map, conflict between local names in {}, offending local name: {}, map so far {}",
                         sia.namespace(), sia.localName(), modifiableNamespacesToAnnotations);
                 throw new IllegalArgumentException("Conflict between local names in " + sia.namespace() + " : " + sia.localName());
             }
@@ -237,7 +237,7 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
         }
         this.namespacesToAnnotations = Collections.unmodifiableMap(modifiableNamespacesToAnnotations);
         this.serviceQNamesToAnnotations = Collections.unmodifiableMap(modifiableServiceQNamesToAnnotations);
-        logger.trace("factoryNamesToQNames:{}", this.factoryNamesToQNames);
+        LOGGER.trace("factoryNamesToQNames:{}", this.factoryNamesToQNames);
     }
 
     @Override
@@ -256,7 +256,7 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
         String factoryName = ObjectNameUtil.getFactoryName(objectName);
         Set<String> serviceInterfaceAnnotations = factoryNamesToQNames.get(factoryName);
         if (serviceInterfaceAnnotations == null) {
-            logger.error("Possible error in code: cannot find factory annotations of '{}' extracted from ON {} in {}",
+            LOGGER.error("Possible error in code: cannot find factory annotations of '{}' extracted from ON {} in {}",
                     factoryName, objectName, factoryNamesToQNames);
             throw new IllegalArgumentException("Cannot find factory with name " + factoryName);
         }
@@ -267,12 +267,12 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
     public synchronized String getServiceInterfaceName(String namespace, String localName) {
         Map<String /* localName */, ServiceInterfaceAnnotation> ofNamespace = namespacesToAnnotations.get(namespace);
         if (ofNamespace == null) {
-            logger.error("Cannot find namespace {} in {}", namespace, namespacesToAnnotations);
+            LOGGER.error("Cannot find namespace {} in {}", namespace, namespacesToAnnotations);
             throw new IllegalArgumentException("Cannot find namespace " + namespace);
         }
         ServiceInterfaceAnnotation sia = ofNamespace.get(localName);
         if (sia == null) {
-            logger.error("Cannot find local name {} in namespace {}, found only {}", localName, namespace, ofNamespace);
+            LOGGER.error("Cannot find local name {} in namespace {}, found only {}", localName, namespace, ofNamespace);
             throw new IllegalArgumentException("Cannot find local name " + localName + " in namespace " + namespace);
         }
         return sia.value();
@@ -300,7 +300,7 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
         try {
             on = lookupRegistry.lookupConfigBean(moduleIdentifier.getFactoryName(), moduleIdentifier.getInstanceName());
         } catch (InstanceNotFoundException e) {
-            logger.error("Cannot find instance {}", moduleIdentifier);
+            LOGGER.error("Cannot find instance {}", moduleIdentifier);
             throw new IllegalStateException("Cannot find instance " + moduleIdentifier, e);
         }
         return on;
@@ -311,7 +311,7 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
         ServiceReference serviceReference = new ServiceReference(serviceInterfaceQName, refName);
         ModuleIdentifier moduleIdentifier = refNames.get(serviceReference);
         if (moduleIdentifier == null) {
-            logger.error("Cannot find qname {} and refName {} in {}", serviceInterfaceQName, refName, refName);
+            LOGGER.error("Cannot find qname {} and refName {} in {}", serviceInterfaceQName, refName, refName);
             throw new IllegalArgumentException("Cannot find " + serviceReference);
         }
         return getObjectName(moduleIdentifier);
@@ -322,7 +322,7 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
         Map<String, Map<String, ObjectName>> serviceMapping = getServiceMapping();
         Map<String, ObjectName> innerMap = serviceMapping.get(serviceInterfaceQName);
         if (innerMap == null) {
-            logger.error("Cannot find qname {} in {}", serviceInterfaceQName, refNames);
+            LOGGER.error("Cannot find qname {} in {}", serviceInterfaceQName, refNames);
             throw new IllegalArgumentException("Cannot find " + serviceInterfaceQName);
         }
         return innerMap;
@@ -348,7 +348,7 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
         String referenceName = ObjectNameUtil.getReferenceName(objectName);
         ServiceReference serviceReference = new ServiceReference(serviceQName, referenceName);
         if (refNames.containsKey(serviceReference) == false) {
-            logger.warn("Cannot find {} in {}", serviceReference, refNames);
+            LOGGER.warn("Cannot find {} in {}", serviceReference, refNames);
             throw new InstanceNotFoundException("Service reference not found:" + objectName);
         }
     }
@@ -387,13 +387,13 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
         // check that service interface name exist
         Set<String> serviceInterfaceQNames = factoryNamesToQNames.get(moduleIdentifier.getFactoryName());
         if (serviceInterfaceQNames == null) {
-            logger.error("Possible error in code: cannot find factoryName {} in {}, {}", moduleIdentifier.getFactoryName(),
+            LOGGER.error("Possible error in code: cannot find factoryName {} in {}, {}", moduleIdentifier.getFactoryName(),
                     factoryNamesToQNames, moduleIdentifier);
             throw new IllegalStateException("Possible error in code: cannot find annotations of existing factory " + moduleIdentifier.getFactoryName());
         }
         // supplied serviceInterfaceName must exist in this collection
         if (serviceInterfaceQNames.contains(serviceReference.getServiceInterfaceQName()) == false) {
-            logger.error("Cannot find qName {} with factory name {}, found {}", serviceReference.getServiceInterfaceQName(), moduleIdentifier.getFactoryName(), serviceInterfaceQNames);
+            LOGGER.error("Cannot find qName {} with factory name {}, found {}", serviceReference.getServiceInterfaceQName(), moduleIdentifier.getFactoryName(), serviceInterfaceQNames);
             throw new IllegalArgumentException("Cannot find service interface " + serviceReference.getServiceInterfaceQName() + " within factory " + moduleIdentifier.getFactoryName());
         }
 
@@ -465,11 +465,11 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
     }
 
     private synchronized void removeServiceReference(ServiceReference serviceReference) throws InstanceNotFoundException {
-        logger.debug("Removing service reference {} from {}", serviceReference, this);
+        LOGGER.debug("Removing service reference {} from {}", serviceReference, this);
         assertWritable();
         // is the qName known?
         if (allQNames.contains(serviceReference.getServiceInterfaceQName()) == false) {
-            logger.error("Cannot find qname {} in {}", serviceReference.getServiceInterfaceQName(), allQNames);
+            LOGGER.error("Cannot find qname {} in {}", serviceReference.getServiceInterfaceQName(), allQNames);
             throw new IllegalArgumentException("Cannot find service interface " + serviceReference.getServiceInterfaceQName());
         }
         ModuleIdentifier removed = refNames.remove(serviceReference);
@@ -518,7 +518,7 @@ public class ServiceReferenceRegistryImpl implements CloseableServiceReferenceRe
     private Set<ServiceReference> findServiceReferencesLinkingTo(ObjectName moduleObjectName, Set<String> serviceInterfaceQNames) {
         String factoryName = ObjectNameUtil.getFactoryName(moduleObjectName);
         if (serviceInterfaceQNames == null) {
-            logger.warn("Possible error in code: cannot find factoryName {} in {}, object name {}", factoryName, factoryNamesToQNames, moduleObjectName);
+            LOGGER.warn("Possible error in code: cannot find factoryName {} in {}, object name {}", factoryName, factoryNamesToQNames, moduleObjectName);
             throw new IllegalStateException("Possible error in code: cannot find annotations of existing factory " + factoryName);
         }
         String instanceName = ObjectNameUtil.getInstanceName(moduleObjectName);
index 4f60a673f5f711ce17815061318f2641bbda0091..a7a67d3d16c734267fd123472880dc598e5f0b28 100644 (file)
@@ -45,7 +45,7 @@ import org.slf4j.LoggerFactory;
  */
 final class DependencyResolverImpl implements DependencyResolver,
         Comparable<DependencyResolverImpl> {
-    private static final Logger logger = LoggerFactory.getLogger(DependencyResolverImpl.class);
+    private static final Logger LOGGER = LoggerFactory.getLogger(DependencyResolverImpl.class);
 
     private final ModulesHolder modulesHolder;
     private final ModuleIdentifier name;
@@ -107,9 +107,9 @@ final class DependencyResolverImpl implements DependencyResolver,
                 ), jmxAttribute
         );
 
-        dependentReadOnlyON = translateServiceRefIfPossible(dependentReadOnlyON);
+        ObjectName newDependentReadOnlyON = translateServiceRefIfPossible(dependentReadOnlyON);
 
-        ModuleIdentifier moduleIdentifier = ObjectNameUtil.fromON(dependentReadOnlyON, ObjectNameUtil
+        ModuleIdentifier moduleIdentifier = ObjectNameUtil.fromON(newDependentReadOnlyON, ObjectNameUtil
                 .TYPE_MODULE);
 
         ModuleFactory foundFactory = modulesHolder.findModuleFactory(moduleIdentifier, jmxAttribute);
@@ -122,7 +122,7 @@ final class DependencyResolverImpl implements DependencyResolver,
                             + "Module name is %s : %s, expected service interface %s, dependent module ON %s , "
                             + "attribute %s",
                     foundFactory.getImplementationName(), foundFactory,
-                    expectedServiceInterface, dependentReadOnlyON,
+                    expectedServiceInterface, newDependentReadOnlyON,
                     jmxAttribute
             );
             throw new JmxAttributeValidationException(message, jmxAttribute);
@@ -134,13 +134,14 @@ final class DependencyResolverImpl implements DependencyResolver,
 
     // translate from serviceref to module ON
     private ObjectName translateServiceRefIfPossible(ObjectName dependentReadOnlyON) {
-        if (ObjectNameUtil.isServiceReference(dependentReadOnlyON)) {
-            String serviceQName = ObjectNameUtil.getServiceQName(dependentReadOnlyON);
-            String refName = ObjectNameUtil.getReferenceName(dependentReadOnlyON);
-            dependentReadOnlyON = ObjectNameUtil.withoutTransactionName( // strip again of transaction name
+        ObjectName translatedDependentReadOnlyON = dependentReadOnlyON;
+        if (ObjectNameUtil.isServiceReference(translatedDependentReadOnlyON)) {
+            String serviceQName = ObjectNameUtil.getServiceQName(translatedDependentReadOnlyON);
+            String refName = ObjectNameUtil.getReferenceName(translatedDependentReadOnlyON);
+            translatedDependentReadOnlyON = ObjectNameUtil.withoutTransactionName( // strip again of transaction name
                     readableRegistry.lookupConfigBeanByServiceInterfaceName(serviceQName, refName));
         }
-        return dependentReadOnlyON;
+        return translatedDependentReadOnlyON;
     }
 
     /**
@@ -155,12 +156,12 @@ final class DependencyResolverImpl implements DependencyResolver,
                     "Null parameters not allowed, got %s %s %s", expectedType,
                     dependentReadOnlyON, jmxAttribute));
         }
-        dependentReadOnlyON = translateServiceRefIfPossible(dependentReadOnlyON);
+        ObjectName translatedDependentReadOnlyON = translateServiceRefIfPossible(dependentReadOnlyON);
         transactionStatus.checkCommitStarted();
         transactionStatus.checkNotCommitted();
 
         ModuleIdentifier dependentModuleIdentifier = ObjectNameUtil.fromON(
-                dependentReadOnlyON, ObjectNameUtil.TYPE_MODULE);
+                translatedDependentReadOnlyON, ObjectNameUtil.TYPE_MODULE);
         Module module = modulesHolder.findModule(dependentModuleIdentifier,
                 jmxAttribute);
         synchronized (this) {
@@ -199,7 +200,7 @@ final class DependencyResolverImpl implements DependencyResolver,
         if (expectedBaseClass.isAssignableFrom(deserialized)) {
             return (Class<T>) deserialized;
         } else {
-            logger.error("Cannot resolve class of identity {} : deserialized class {} is not a subclass of {}.",
+            LOGGER.error("Cannot resolve class of identity {} : deserialized class {} is not a subclass of {}.",
                     identityRef, deserialized, expectedBaseClass);
             throw new IllegalArgumentException("Deserialized identity " + deserialized + " cannot be cast to " + expectedBaseClass);
         }
@@ -277,17 +278,17 @@ final class DependencyResolverImpl implements DependencyResolver,
     @Override
     public Object getAttribute(ObjectName name, String attribute)
             throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException {
-        name = translateServiceRefIfPossible(name);
+        ObjectName newName = translateServiceRefIfPossible(name);
         // add transaction name
-        name = ObjectNameUtil.withTransactionName(name, transactionName);
-        return mBeanServer.getAttribute(name, attribute);
+        newName = ObjectNameUtil.withTransactionName(newName, transactionName);
+        return mBeanServer.getAttribute(newName, attribute);
     }
 
     @Override
     public <T> T newMXBeanProxy(ObjectName name, Class<T> interfaceClass) {
-        name = translateServiceRefIfPossible(name);
+        ObjectName newName = translateServiceRefIfPossible(name);
         // add transaction name
-        name = ObjectNameUtil.withTransactionName(name, transactionName);
-        return JMX.newMXBeanProxy(mBeanServer, name, interfaceClass);
+        newName = ObjectNameUtil.withTransactionName(newName, transactionName);
+        return JMX.newMXBeanProxy(mBeanServer, newName, interfaceClass);
     }
 }
index 2a1a908e7a18875c1baed6997fe9a6e5f6848519..15f5d48a6f51f43decd567129ce5d0854cc9ddcb 100644 (file)
@@ -139,7 +139,7 @@ public class DependencyResolverManager implements DependencyResolverFactory, Aut
 
             @Override
             protected Object handleInvocation(Object proxy, Method method, Object[] args) throws Throwable {
-                boolean isGetInstance = method.getName().equals("getInstance");
+                boolean isGetInstance = "getInstance".equals(method.getName());
                 if (isGetInstance) {
                     if (cachedInstance != null) {
                         return cachedInstance;
index 2aa74758d47c6fd2c7cc6b1fa095695ea8e91ded..ec2418bc6c902749ba72896aeb3924e62dac381e 100644 (file)
@@ -22,7 +22,7 @@ import org.slf4j.LoggerFactory;
  */
 public class DestroyedModule implements AutoCloseable,
         Comparable<DestroyedModule>, Identifiable<ModuleIdentifier> {
-    private static final Logger logger = LoggerFactory
+    private static final Logger LOGGER = LoggerFactory
             .getLogger(DestroyedModule.class);
 
     private final ModuleIdentifier identifier;
@@ -43,21 +43,21 @@ public class DestroyedModule implements AutoCloseable,
 
     @Override
     public void close() {
-        logger.trace("Destroying {}", identifier);
+        LOGGER.trace("Destroying {}", identifier);
         try {
             instance.close();
         } catch (Exception e) {
-            logger.error("Error while closing instance of {}", identifier, e);
+            LOGGER.error("Error while closing instance of {}", identifier, e);
         }
         try {
             oldJMXRegistrator.close();
         } catch (Exception e) {
-            logger.error("Error while closing jmx registrator of {}", identifier, e);
+            LOGGER.error("Error while closing jmx registrator of {}", identifier, e);
         }
         try {
             osgiRegistration.close();
         } catch (Exception e) {
-            logger.error("Error while closing osgi registration of {}", identifier, e);
+            LOGGER.error("Error while closing osgi registration of {}", identifier, e);
         }
     }
 
index 7e48af1caae9adc31cb0c76b64a86d0fb7bca428..4a148669b16eaabaf076d41f7f89e56e6169786c 100644 (file)
@@ -57,7 +57,7 @@ import static java.lang.String.format;
  * a read only wrapper.
  */
 abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
-    private static final Logger logger = LoggerFactory
+    private static final Logger LOGGER = LoggerFactory
             .getLogger(AbstractDynamicWrapper.class);
 
     protected final boolean writable;
@@ -234,7 +234,7 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
     public Object getAttribute(String attributeName)
             throws AttributeNotFoundException, MBeanException,
             ReflectionException {
-        if (attributeName.equals("MBeanInfo")) {
+        if ("MBeanInfo".equals(attributeName)) {
             return getMBeanInfo();
         }
 
@@ -318,7 +318,7 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
                 result.add(new Attribute(attributeName, value));
 
             } catch (Exception e) {
-                logger.debug("Getting attribute {} failed", attributeName, e);
+                LOGGER.debug("Getting attribute {} failed", attributeName, e);
             }
         }
         return result;
@@ -342,7 +342,7 @@ abstract class AbstractDynamicWrapper implements DynamicMBeanModuleWrapper {
                 && signature[0].equals(AttributeList.class.getName())) {
             return setAttributes((AttributeList) params[0]);
         } else {
-            logger.debug("Operation not found {} ", actionName);
+            LOGGER.debug("Operation not found {} ", actionName);
             throw new UnsupportedOperationException(
                     format("Operation not found on %s. Method invoke is only supported for getInstance and getAttribute(s) "
                             + "method, got actionName %s, params %s, signature %s ",
index f3e1b4e705c3b943230d13ee52eca44bd798b930..c4dee3513d6e5bedd9376ddf64f6405c0c76647b 100644 (file)
@@ -17,6 +17,9 @@ import java.util.Set;
 
 public class AnnotationsHelper {
 
+    private AnnotationsHelper() {
+    }
+
     /**
      * Look for annotation specified by annotationType on method. First observe
      * method's class, then its super classes, then all provided interfaces.
index 044f7a9ada06af871fad5bc1cad531e550bab8c8..14be2545047a87af8b1e514d0b81632cd3d71c06 100644 (file)
@@ -136,7 +136,7 @@ class AttributeHolder {
         for (RequireInterface ri : foundRequireInterfaces) {
             foundValues.add(ri.value());
         }
-        if (foundValues.size() == 0) {
+        if (foundValues.isEmpty()) {
             return null;
         } else if (foundValues.size() > 1) {
             throw new IllegalStateException("Error finding @RequireInterface. "
index 3a24940a4c058ba91155dcd15ca42e3a86443b4c..7d3cb277fb2405cf59b81a9b73d0896575eac0c7 100644 (file)
@@ -68,7 +68,7 @@ public class DynamicReadableWrapper extends AbstractDynamicWrapper implements
     public Object getAttribute(String attributeName)
             throws AttributeNotFoundException, MBeanException,
             ReflectionException {
-        if (attributeName.equals("getInstance")) {
+        if ("getInstance".equals(attributeName)) {
             return getInstance();
         }
         return super.getAttribute(attributeName);
index 07bd63b7c7be8c78397b227ae40db7e53cb8da91..c3885150d572f80d1000320678424e597d2558ce 100644 (file)
@@ -47,7 +47,7 @@ import java.lang.reflect.Method;
  */
 @ThreadSafe
 public class DynamicWritableWrapper extends AbstractDynamicWrapper {
-    private static final Logger logger = LoggerFactory
+    private static final Logger LOGGER = LoggerFactory
             .getLogger(DynamicWritableWrapper.class);
 
     private final ReadOnlyAtomicBoolean configBeanModificationDisabled;
@@ -77,23 +77,24 @@ public class DynamicWritableWrapper extends AbstractDynamicWrapper {
     @Override
     public synchronized void setAttribute(Attribute attribute)
             throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException {
+        Attribute newAttribute = attribute;
         if (configBeanModificationDisabled.get() == true) {
             throw new IllegalStateException("Operation is not allowed now");
         }
 
-        if (attribute.getName().equals("Attribute")) {
-            setAttribute((Attribute) attribute.getValue());
+        if ("Attribute".equals(newAttribute.getName())) {
+            setAttribute((Attribute) newAttribute.getValue());
             return;
         }
 
         try {
-            if (attribute.getValue() instanceof ObjectName) {
-                attribute = fixDependencyAttribute(attribute);
-            } else if (attribute.getValue() instanceof ObjectName[]) {
-                attribute = fixDependencyListAttribute(attribute);
+            if (newAttribute.getValue() instanceof ObjectName) {
+                newAttribute = fixDependencyAttribute(newAttribute);
+            } else if (newAttribute.getValue() instanceof ObjectName[]) {
+                newAttribute = fixDependencyListAttribute(newAttribute);
             }
 
-            internalServer.setAttribute(objectNameInternal, attribute);
+            internalServer.setAttribute(objectNameInternal, newAttribute);
         } catch (InstanceNotFoundException e) {
             throw new MBeanException(e);
         }
@@ -101,21 +102,23 @@ public class DynamicWritableWrapper extends AbstractDynamicWrapper {
     }
 
     private Attribute fixDependencyListAttribute(Attribute attribute) {
-        AttributeHolder attributeHolder = attributeHolderMap.get(attribute.getName());
+        Attribute newAttribute = attribute;
+        AttributeHolder attributeHolder = attributeHolderMap.get(newAttribute.getName());
         if (attributeHolder.getRequireInterfaceOrNull() != null) {
-            attribute = new Attribute(attribute.getName(), fixObjectNames((ObjectName[]) attribute.getValue()));
+            newAttribute = new Attribute(newAttribute.getName(), fixObjectNames((ObjectName[]) newAttribute.getValue()));
         }
-        return attribute;
+        return newAttribute;
     }
 
     private Attribute fixDependencyAttribute(Attribute attribute) {
-        AttributeHolder attributeHolder = attributeHolderMap.get(attribute.getName());
+        Attribute newAttribute = attribute;
+        AttributeHolder attributeHolder = attributeHolderMap.get(newAttribute.getName());
         if (attributeHolder.getRequireInterfaceOrNull() != null) {
-            attribute = new Attribute(attribute.getName(), fixObjectName((ObjectName) attribute.getValue()));
+            newAttribute = new Attribute(newAttribute.getName(), fixObjectName((ObjectName) newAttribute.getValue()));
         } else {
-            attribute = new Attribute(attribute.getName(), attribute.getValue());
+            newAttribute = new Attribute(newAttribute.getName(), newAttribute.getValue());
         }
-        return attribute;
+        return newAttribute;
     }
 
     private ObjectName[] fixObjectNames(ObjectName[] dependencies) {
@@ -137,7 +140,7 @@ public class DynamicWritableWrapper extends AbstractDynamicWrapper {
                 setAttribute(attribute);
                 result.add(attribute);
             } catch (Exception e) {
-                logger.warn("Setting attribute {} failed on {}", attribute.getName(), moduleIdentifier, e);
+                LOGGER.warn("Setting attribute {} failed on {}", attribute.getName(), moduleIdentifier, e);
                 throw new IllegalArgumentException(
                         "Setting attribute failed - " + attribute.getName()
                                 + " on " + moduleIdentifier, e);
index 98f0908dc710cf40fbb93b88004d411d03f594fd..f8bbee3e59399c51927b5e3ff14812a9a2e61c23 100644 (file)
@@ -27,7 +27,7 @@ import java.util.List;
 import java.util.Set;
 
 public class InternalJMXRegistrator implements Closeable {
-    private static final Logger logger = LoggerFactory
+    private static final Logger LOGGER = LoggerFactory
             .getLogger(InternalJMXRegistrator.class);
     private final MBeanServer configMBeanServer;
 
@@ -100,7 +100,7 @@ public class InternalJMXRegistrator implements Closeable {
             try {
                 configMBeanServer.unregisterMBean(on);
             } catch (Exception e) {
-                logger.warn("Ignoring error while unregistering {}", on, e);
+                LOGGER.warn("Ignoring error while unregistering {}", on, e);
             }
         }
         registeredObjectNames.clear();
index 34c0436dafe2dec31fda777eb0f7754ab16dddfa..c0e9b0d101b30bd912ff2674ccc254744356a68f 100644 (file)
@@ -46,9 +46,10 @@ public class ModuleJMXRegistrator implements Closeable {
     public ModuleJMXRegistration registerMBean(Object object, ObjectName on)
             throws InstanceAlreadyExistsException {
         ObjectNameUtil.checkType(on, ObjectNameUtil.TYPE_MODULE);
-        if (ObjectNameUtil.getTransactionName(on) != null)
+        if (ObjectNameUtil.getTransactionName(on) != null) {
             throw new IllegalArgumentException(
                     "Transaction name not expected in " + on);
+        }
         return new ModuleJMXRegistration(childJMXRegistrator.registerMBean(
                 object, on));
     }
index b592fa3c79736d09b22f0b133bef142702783dbb..c03bfa450034254360dca663f18abf54d607f83e 100644 (file)
@@ -49,7 +49,7 @@ public class BeanToOsgiServiceManager {
 
 
     public static class OsgiRegistration implements AutoCloseable {
-        private static final Logger logger = LoggerFactory.getLogger(OsgiRegistration.class);
+        private static final Logger LOGGER = LoggerFactory.getLogger(OsgiRegistration.class);
 
         @GuardedBy("this")
         private AutoCloseable instance;
@@ -89,7 +89,7 @@ public class BeanToOsgiServiceManager {
                 try {
                     serviceRegistration.unregister();
                 } catch(IllegalStateException e) {
-                    logger.trace("Cannot unregister {}", serviceRegistration, e);
+                    LOGGER.trace("Cannot unregister {}", serviceRegistration, e);
                 }
             }
             serviceRegistrations.clear();
@@ -101,7 +101,7 @@ public class BeanToOsgiServiceManager {
             notEquals |= newAnnotationMapping.equals(serviceNamesToAnnotations) == false;
             if (notEquals) {
                 // FIXME: changing from old state to new state can be improved by computing the diff
-                logger.debug("Detected change in service registrations for {}: old: {}, new: {}", moduleIdentifier,
+                LOGGER.debug("Detected change in service registrations for {}: old: {}, new: {}", moduleIdentifier,
                         serviceNamesToAnnotations, newAnnotationMapping);
                 close();
                 this.instance = newInstance;
index 375ef5948712f3bcc5dc803802645b1d6fa56103..b115f1acd94ef837c8b7309be87a86e41e1fd195 100644 (file)
@@ -25,7 +25,7 @@ import org.slf4j.LoggerFactory;
  * functionality.
  */
 public class BlankTransactionServiceTracker implements ServiceTrackerCustomizer<ModuleFactory, Object> {
-    private static final Logger logger = LoggerFactory.getLogger(BlankTransactionServiceTracker.class);
+    private static final Logger LOGGER = LoggerFactory.getLogger(BlankTransactionServiceTracker.class);
 
     public static final int DEFAULT_MAX_ATTEMPTS = 10;
 
@@ -65,7 +65,7 @@ public class BlankTransactionServiceTracker implements ServiceTrackerCustomizer<
             try {
                 // create transaction
                 CommitStatus commitStatus = blankTransaction.hit();
-                logger.debug("Committed blank transaction with status {}", commitStatus);
+                LOGGER.debug("Committed blank transaction with status {}", commitStatus);
                 return;
             } catch (ConflictingVersionException e) {
                 lastException = e;
@@ -76,7 +76,7 @@ public class BlankTransactionServiceTracker implements ServiceTrackerCustomizer<
                     throw new IllegalStateException(interruptedException);
                 }
             } catch (ValidationException e) {
-                logger.error("Validation exception while running blank transaction indicates programming error", e);
+                LOGGER.error("Validation exception while running blank transaction indicates programming error", e);
                 throw new RuntimeException("Validation exception while running blank transaction indicates programming error", e);
             }
         }
index 1e94e5e9c021b1660e02a6d8303333832716ad44..7cb4445328f84355e86ad8590120340354e7df6c 100644 (file)
@@ -25,7 +25,7 @@ import java.util.Map;
  */
 public class BundleContextBackedModuleFactoriesResolver implements
         ModuleFactoriesResolver {
-    private static final Logger logger = LoggerFactory
+    private static final Logger LOGGER = LoggerFactory
             .getLogger(BundleContextBackedModuleFactoriesResolver.class);
     private final BundleContext bundleContext;
 
@@ -62,14 +62,14 @@ 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);
+            LOGGER.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);
+                LOGGER.error(error);
                 throw new IllegalArgumentException(error);
             } else {
                 result.put(moduleName, new AbstractMap.SimpleImmutableEntry<>(factory,
index 3015ed229e28f1c04015d9d488d641c9ebceb161..3c8fc042a37c5ebe048b8b1e47a1016674b6402c 100644 (file)
@@ -35,7 +35,7 @@ import org.slf4j.LoggerFactory;
  */
 public class ModuleFactoryBundleTracker implements BundleTrackerCustomizer<Object> {
     private final BlankTransactionServiceTracker blankTransactionServiceTracker;
-    private static final Logger logger = LoggerFactory.getLogger(ModuleFactoryBundleTracker.class);
+    private static final Logger LOGGER = LoggerFactory.getLogger(ModuleFactoryBundleTracker.class);
 
     public ModuleFactoryBundleTracker(BlankTransactionServiceTracker blankTransactionServiceTracker) {
         this.blankTransactionServiceTracker = blankTransactionServiceTracker;
@@ -44,7 +44,7 @@ public class ModuleFactoryBundleTracker implements BundleTrackerCustomizer<Objec
     @Override
     public Object addingBundle(Bundle bundle, BundleEvent event) {
         URL resource = bundle.getEntry("META-INF/services/" + ModuleFactory.class.getName());
-        logger.trace("Got addingBundle event of bundle {}, resource {}, event {}",
+        LOGGER.trace("Got addingBundle event of bundle {}, resource {}, event {}",
                 bundle, resource, event);
         if (resource != null) {
             try (InputStream inputStream = resource.openStream()) {
@@ -53,7 +53,7 @@ public class ModuleFactoryBundleTracker implements BundleTrackerCustomizer<Objec
                     registerFactory(factoryClassName, bundle);
                 }
             } catch (Exception e) {
-                logger.error("Error while reading {}", resource, e);
+                LOGGER.error("Error while reading {}", resource, e);
                 throw new RuntimeException(e);
             }
         }
@@ -79,7 +79,7 @@ public class ModuleFactoryBundleTracker implements BundleTrackerCustomizer<Objec
             Class<?> clazz = bundle.loadClass(factoryClassName);
             if (ModuleFactory.class.isAssignableFrom(clazz)) {
                 try {
-                    logger.debug("Registering {} in bundle {}",
+                    LOGGER.debug("Registering {} in bundle {}",
                             clazz.getName(), bundle);
                     return bundle.getBundleContext().registerService(
                             ModuleFactory.class.getName(), clazz.newInstance(),
@@ -111,7 +111,7 @@ public class ModuleFactoryBundleTracker implements BundleTrackerCustomizer<Objec
     }
 
     public static String logMessage(String slfMessage, Object... params) {
-        logger.info(slfMessage, params);
+        LOGGER.info(slfMessage, params);
         String formatMessage = slfMessage.replaceAll("\\{\\}", "%s");
         return format(formatMessage, params);
     }
index 48fdd8855de12c9735a9a10a25ae5b5a9382b7f0..c5be03ca4dc1948fe776ef30b5d171ec0667ce83 100644 (file)
@@ -31,7 +31,7 @@ import org.slf4j.LoggerFactory;
  */
 public final class ModuleInfoBundleTracker implements BundleTrackerCustomizer<Collection<ObjectRegistration<YangModuleInfo>>> {
 
-    private static final Logger logger = LoggerFactory.getLogger(ModuleInfoBundleTracker.class);
+    private static final Logger LOGGER = LoggerFactory.getLogger(ModuleInfoBundleTracker.class);
 
     public static final String MODULE_INFO_PROVIDER_PATH_PREFIX = "META-INF/services/";
 
@@ -45,7 +45,7 @@ public final class ModuleInfoBundleTracker implements BundleTrackerCustomizer<Co
     @Override
     public Collection<ObjectRegistration<YangModuleInfo>> addingBundle(Bundle bundle, BundleEvent event) {
         URL resource = bundle.getEntry(MODULE_INFO_PROVIDER_PATH_PREFIX + YangModelBindingProvider.class.getName());
-        logger.debug("Got addingBundle({}) with YangModelBindingProvider resource {}", bundle, resource);
+        LOGGER.debug("Got addingBundle({}) with YangModelBindingProvider resource {}", bundle, resource);
         if(resource==null) {
             return null;
         }
@@ -54,16 +54,16 @@ public final class ModuleInfoBundleTracker implements BundleTrackerCustomizer<Co
         try (InputStream inputStream = resource.openStream()) {
             List<String> lines = IOUtils.readLines(inputStream);
             for (String moduleInfoName : lines) {
-                logger.trace("Retrieve ModuleInfo({}, {})", moduleInfoName, bundle);
+                LOGGER.trace("Retrieve ModuleInfo({}, {})", moduleInfoName, bundle);
                 YangModuleInfo moduleInfo = retrieveModuleInfo(moduleInfoName, bundle);
                 registrations.add(moduleInfoRegistry.registerModuleInfo(moduleInfo));
             }
 
         } catch (Exception e) {
-            logger.error("Error while reading {}", resource, e);
+            LOGGER.error("Error while reading {}", resource, e);
             throw new RuntimeException(e);
         }
-        logger.trace("Got following registrations {}", registrations);
+        LOGGER.trace("Got following registrations {}", registrations);
         return registrations;
     }
 
@@ -111,7 +111,7 @@ public final class ModuleInfoBundleTracker implements BundleTrackerCustomizer<Co
         } catch (NoClassDefFoundError e) {
 
 
-            logger.error("Error while executing getModuleInfo on {}", instance, e);
+            LOGGER.error("Error while executing getModuleInfo on {}", instance, e);
             throw e;
         }
     }
@@ -126,7 +126,7 @@ public final class ModuleInfoBundleTracker implements BundleTrackerCustomizer<Co
     }
 
     public static String logMessage(String slfMessage, Object... params) {
-        logger.info(slfMessage, params);
+        LOGGER.info(slfMessage, params);
         String formatMessage = slfMessage.replaceAll("\\{\\}", "%s");
         return format(formatMessage, params);
     }
index 510fdf9373f46a7dc0c5f1aa61aabd15d31fbb25..4d94c6d2655650ece2f9bcb1a26a3e0b872a7d60 100644 (file)
@@ -21,6 +21,9 @@ import java.util.Set;
 
 public class InterfacesHelper {
 
+    private InterfacesHelper() {
+    }
+
     public static Set<Class<?>> getAllInterfaces(Class<?> clazz) {
         if (clazz.isInterface()) {
             throw new IllegalArgumentException(clazz
@@ -38,17 +41,17 @@ public class InterfacesHelper {
     }
 
     private static Set<Class<?>> getAllSuperInterfaces(Set<Class<?>> ifcs) {
-        ifcs = new HashSet<>(ifcs); // create copy to modify
+        Set<Class<?>> interfaces = new HashSet<>(ifcs); // create copy to modify
         // each interface can extend other interfaces
         Set<Class<?>> result = new HashSet<>();
-        while (ifcs.size() > 0) {
-            Iterator<Class<?>> iterator = ifcs.iterator();
+        while (!interfaces.isEmpty()) {
+            Iterator<Class<?>> iterator = interfaces.iterator();
             Class<?> ifc = iterator.next();
             iterator.remove();
             if (ifc.isInterface() == false)  {
                 throw new IllegalArgumentException(ifc + " should be an interface");
             }
-            ifcs.addAll(Arrays.asList(ifc.getInterfaces()));
+            interfaces.addAll(Arrays.asList(ifc.getInterfaces()));
             result.add(ifc);
         }
         return result;
index fdde0b23efc53daf2f9b7a33001eb9cad1d4fb6c..284e109f2d11fc0b7d83cd45cf9dfc8cb6605151 100644 (file)
@@ -16,12 +16,15 @@ import org.opendaylight.controller.config.api.LookupRegistry;
 
 public class LookupBeansUtil {
 
+    private LookupBeansUtil() {
+    }
+
     public static ObjectName lookupConfigBean(LookupRegistry lookupRegistry,
             String moduleName, String instanceName)
             throws InstanceNotFoundException {
         Set<ObjectName> objectNames = lookupRegistry.lookupConfigBeans(
                 moduleName, instanceName);
-        if (objectNames.size() == 0) {
+        if (objectNames.isEmpty()) {
             throw new InstanceNotFoundException("No instance found");
         } else if (objectNames.size() > 1) {
             throw new InstanceNotFoundException("Too many instances found");
index f1072a76ae907d934d13984478c119092c9f0dbd..1cb31caea166d62dbc7c343b30b3ad2c440f6f58 100644 (file)
@@ -19,6 +19,9 @@ import java.util.Set;
 
 public class ModuleQNameUtil {
 
+    private ModuleQNameUtil() {
+    }
+
     public static Set<String> getQNames(Map<String, Entry<ModuleFactory, BundleContext>> resolved) {
         Set<String> result = new HashSet<>();
         for (Entry<ModuleFactory, BundleContext> entry : resolved.values()) {
index 2df28f0a154b8b7a6e37f1930b5e06d46efda675..f839452dcadb8e1295e8a1669154ea51699af5f5 100644 (file)
@@ -21,7 +21,10 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class OsgiRegistrationUtil {
-    private static final Logger logger = LoggerFactory.getLogger(OsgiRegistrationUtil.class);
+    private static final Logger LOGGER = LoggerFactory.getLogger(OsgiRegistrationUtil.class);
+
+    private OsgiRegistrationUtil() {
+    }
 
     @SafeVarargs
     public static <T> AutoCloseable registerService(BundleContext bundleContext, T service, Class<? super T> ... interfaces) {
@@ -80,7 +83,7 @@ public class OsgiRegistrationUtil {
                     try {
                         ac.close();
                     } catch (Exception e) {
-                        logger.warn("Exception while closing {}", ac, e);
+                        LOGGER.warn("Exception while closing {}", ac, e);
                         if (firstException == null) {
                             firstException = e;
                         } else {
index 1bf2025c46ee3af3085f77ab6fdf166a54b71846..3e004b4d7cf03a99a7bcfb4e2906f0c437fadf73 100644 (file)
@@ -30,7 +30,7 @@ import com.google.common.base.Preconditions;
  * Delegates the the contained feature and provides additional methods.
  */
 public class AbstractFeatureWrapper implements Feature {
-    private static final Logger logger = LoggerFactory.getLogger(AbstractFeatureWrapper.class);
+    private static final Logger LOGGER = LoggerFactory.getLogger(AbstractFeatureWrapper.class);
     protected Feature feature = null;
 
     protected AbstractFeatureWrapper() {
@@ -55,7 +55,7 @@ public class AbstractFeatureWrapper implements Feature {
             try {
                 snapShotHolders.add(new FeatureConfigSnapshotHolder(c,this));
             } catch (JAXBException e) {
-                logger.debug("{} is not a config subsystem config file",c.getFinalname());
+                LOGGER.debug("{} is not a config subsystem config file",c.getFinalname());
             }
         }
         return snapShotHolders;
@@ -71,18 +71,23 @@ public class AbstractFeatureWrapper implements Feature {
 
     @Override
     public boolean equals(Object obj) {
-        if (this == obj)
+        if (this == obj) {
             return true;
-        if (obj == null)
+        }
+        if (obj == null) {
             return false;
-        if (getClass() != obj.getClass())
+        }
+        if (getClass() != obj.getClass()) {
             return false;
+        }
         AbstractFeatureWrapper other = (AbstractFeatureWrapper) obj;
         if (feature == null) {
-            if (other.feature != null)
+            if (other.feature != null) {
                 return false;
-        } else if (!feature.equals(other.feature))
+            }
+        } else if (!feature.equals(other.feature)) {
             return false;
+        }
         return true;
     }
 
index 8d2ae68a9a3af76c8f0db7c8f50b8739bb25888b..2bff9069007baa515c8f175740a79fe5e1b325a4 100644 (file)
@@ -30,7 +30,7 @@ import com.google.common.base.Preconditions;
  * Delegates the the contained feature and provides additional methods.
  */
 public class ChildAwareFeatureWrapper extends AbstractFeatureWrapper implements Feature {
-    private static final Logger logger = LoggerFactory.getLogger(ChildAwareFeatureWrapper.class);
+    private static final Logger LOGGER = LoggerFactory.getLogger(ChildAwareFeatureWrapper.class);
     private FeaturesService featuresService= null;
 
     protected ChildAwareFeatureWrapper(Feature f) {
@@ -79,7 +79,7 @@ public class ChildAwareFeatureWrapper extends AbstractFeatureWrapper implements
                     f = new FeatureConfigSnapshotHolder(h,this);
                     snapShotHolders.add(f);
                 } catch (JAXBException e) {
-                    logger.debug("{} is not a config subsystem config file",h.getFileInfo().getFinalname());
+                    LOGGER.debug("{} is not a config subsystem config file",h.getFileInfo().getFinalname());
                 }
             }
         }
@@ -95,11 +95,10 @@ public class ChildAwareFeatureWrapper extends AbstractFeatureWrapper implements
         for(Feature f: features) {
             if (f.getName().equals(dependency.getName())) {
                 Version v = VersionTable.getVersion(f.getVersion());
-                if (range.contains(v)) {
-                    if (fi == null || VersionTable.getVersion(fi.getVersion()).compareTo(v) < 0) {
+                if (range.contains(v) &&
+                    (fi == null || VersionTable.getVersion(fi.getVersion()).compareTo(v) < 0)) {
                         fi = f;
                         break;
-                    }
                 }
             }
         }
index b8f18960d109f60d5d33e3683035784387ee0a86..2af471999497dde9d933338e8b66526133e2bbc3 100644 (file)
@@ -19,7 +19,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class ConfigFeaturesListener implements  FeaturesListener,  AutoCloseable {
-    private static final Logger logger = LoggerFactory.getLogger(ConfigFeaturesListener.class);
+    private static final Logger LOGGER = LoggerFactory.getLogger(ConfigFeaturesListener.class);
     private static final int QUEUE_SIZE = 1000;
     private BlockingQueue<FeatureEvent> queue = new LinkedBlockingQueue<FeatureEvent>(QUEUE_SIZE);
     Thread pushingThread = null;
@@ -36,7 +36,7 @@ public class ConfigFeaturesListener implements  FeaturesListener,  AutoCloseable
 
     @Override
     public void repositoryEvent(RepositoryEvent event) {
-        logger.debug("Repository: " + event.getType() + " " + event.getRepository());
+        LOGGER.debug("Repository: " + event.getType() + " " + event.getRepository());
     }
 
     @Override
index d33a8cba92bb552dd8db19f2daebe1c5ccc60c51..abb1dbe9aa060617fc5ac638cb0439a087b2a3a2 100644 (file)
@@ -17,14 +17,14 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class ConfigPusherCustomizer implements ServiceTrackerCustomizer<ConfigPusher, ConfigPusher>, AutoCloseable {
-    private static final Logger logger = LoggerFactory.getLogger(ConfigPusherCustomizer.class);
+    private static final Logger LOGGER = LoggerFactory.getLogger(ConfigPusherCustomizer.class);
     private ConfigFeaturesListener configFeaturesListener = null;
     private FeatureServiceCustomizer featureServiceCustomizer = null;
     private ServiceTracker<FeaturesService,FeaturesService> fsst = null;
 
     @Override
     public ConfigPusher addingService(ServiceReference<ConfigPusher> configPusherServiceReference) {
-        logger.trace("Got ConfigPusherCustomizer.addingService {}", configPusherServiceReference);
+        LOGGER.trace("Got ConfigPusherCustomizer.addingService {}", configPusherServiceReference);
         BundleContext bc = configPusherServiceReference.getBundle().getBundleContext();
         ConfigPusher cpService = bc.getService(configPusherServiceReference);
         featureServiceCustomizer = new FeatureServiceCustomizer(cpService);
index 06c5c920f4ebb4da149e591c14d3c944cd4ccd5b..b0e64b84d2adf4433fd378b8fca5d35eb97c4e19 100644 (file)
@@ -23,7 +23,7 @@ import org.slf4j.LoggerFactory;
 import com.google.common.collect.LinkedHashMultimap;
 
 public class ConfigPushingRunnable implements Runnable {
-    private static final Logger logger = LoggerFactory.getLogger(ConfigPushingRunnable.class);
+    private static final Logger LOGGER = LoggerFactory.getLogger(ConfigPushingRunnable.class);
     private static final int POLL_TIME = 1;
     private BlockingQueue<FeatureEvent> queue;
     private FeatureConfigPusher configPusher;
@@ -49,14 +49,14 @@ public class ConfigPushingRunnable implements Runnable {
                             processFeatureEvent(event,toInstall);
                         }
                 } else if(toInstall.isEmpty()) {
-                    logger.error("ConfigPushingRunnable - exiting");
+                    LOGGER.error("ConfigPushingRunnable - exiting");
                     return;
                 }
             } catch (InterruptedException e) {
-                logger.error("ConfigPushingRunnable - interupted");
+                LOGGER.error("ConfigPushingRunnable - interupted");
                 interuppted = true;
             } catch (Exception e) {
-                logger.error("Exception while processing features {}", e);
+                LOGGER.error("Exception while processing features {}", e);
             }
         }
     }
@@ -73,7 +73,7 @@ public class ConfigPushingRunnable implements Runnable {
 
     protected void logPushResult(LinkedHashMultimap<Feature,FeatureConfigSnapshotHolder> results) {
         for(Feature f:results.keySet()) {
-            logger.info("Pushed configs for feature {} {}",f,results.get(f));
+            LOGGER.info("Pushed configs for feature {} {}",f,results.get(f));
         }
     }
 }
index 17099f9d3355d948c877538bc76b0f1f8f21285e..5c5061277b62f28c98e163f17c7fc1c721a91cd9 100644 (file)
@@ -25,7 +25,7 @@ import com.google.common.collect.LinkedHashMultimap;
  * Simple class to push configs to the config subsystem from Feature's configfiles
  */
 public class FeatureConfigPusher {
-    private static final Logger logger = LoggerFactory.getLogger(FeatureConfigPusher.class);
+    private static final Logger LOGGER = LoggerFactory.getLogger(FeatureConfigPusher.class);
     private static final int MAX_RETRIES=100;
     private static final int RETRY_PAUSE_MILLIS=1;
     private FeaturesService featuresService = null;
@@ -90,13 +90,13 @@ public class FeatureConfigPusher {
                 if(installedFeatures.contains(feature)) {
                     return true;
                 } else {
-                    logger.warn("Karaf featuresService.listInstalledFeatures() has not yet finished installing feature (retry {}) {} {}",retries,feature.getName(),feature.getVersion());
+                    LOGGER.warn("Karaf featuresService.listInstalledFeatures() has not yet finished installing feature (retry {}) {} {}",retries,feature.getName(),feature.getVersion());
                 }
             } catch (Exception e) {
                 if(retries < MAX_RETRIES) {
-                    logger.warn("Karaf featuresService.listInstalledFeatures() has thrown an exception, retry {}, Exception {}", retries,e);
+                    LOGGER.warn("Karaf featuresService.listInstalledFeatures() has thrown an exception, retry {}, Exception {}", retries,e);
                 } else {
-                    logger.error("Giving up on Karaf featuresService.listInstalledFeatures() which has thrown an exception, retry {}, Exception {}", retries,e);
+                    LOGGER.error("Giving up on Karaf featuresService.listInstalledFeatures() which has thrown an exception, retry {}, Exception {}", retries,e);
                     throw e;
                 }
             }
@@ -106,7 +106,7 @@ public class FeatureConfigPusher {
                 throw new IllegalStateException(e1);
             }
         }
-        logger.error("Giving up (after {} retries) on Karaf featuresService.listInstalledFeatures() which has not yet finished installing feature {} {}",MAX_RETRIES,feature.getName(),feature.getVersion());
+        LOGGER.error("Giving up (after {} retries) on Karaf featuresService.listInstalledFeatures() which has not yet finished installing feature {} {}",MAX_RETRIES,feature.getName(),feature.getVersion());
         return false;
     }
 
index e75c62b81db8dce90184d7142042a00fbce3a88f..02f9f8b80a4e0d4483249359c4272223affa23fd 100644 (file)
@@ -31,7 +31,7 @@ import java.util.SortedSet;
  * StorageAdapter that stores configuration in an xml file.
  */
 public class XmlFileStorageAdapter implements StorageAdapter, Persister {
-    private static final Logger logger = LoggerFactory.getLogger(XmlFileStorageAdapter.class);
+    private static final Logger LOGGER = LoggerFactory.getLogger(XmlFileStorageAdapter.class);
 
     public static final String FILE_STORAGE_PROP = "fileStorage";
     public static final String NUMBER_OF_BACKUPS = "numberOfBackups";
@@ -42,15 +42,15 @@ public class XmlFileStorageAdapter implements StorageAdapter, Persister {
     @Override
     public Persister instantiate(PropertiesProvider propertiesProvider) {
         File storage = extractStorageFileFromProperties(propertiesProvider);
-        logger.debug("Using file {}", storage.getAbsolutePath());
+        LOGGER.debug("Using file {}", storage.getAbsolutePath());
         // Create file if it does not exist
         File parentFile = storage.getAbsoluteFile().getParentFile();
         if (parentFile.exists() == false) {
-            logger.debug("Creating parent folders {}", parentFile);
+            LOGGER.debug("Creating parent folders {}", parentFile);
             parentFile.mkdirs();
         }
         if (storage.exists() == false) {
-            logger.debug("Storage file does not exist, creating empty file");
+            LOGGER.debug("Storage file does not exist, creating empty file");
             try {
                 boolean result = storage.createNewFile();
                 if (result == false)
@@ -87,7 +87,7 @@ public class XmlFileStorageAdapter implements StorageAdapter, Persister {
         } else {
             numberOfStoredBackups = Integer.MAX_VALUE;
         }
-        logger.trace("Property {} set to {}", NUMBER_OF_BACKUPS, numberOfStoredBackups);
+        LOGGER.trace("Property {} set to {}", NUMBER_OF_BACKUPS, numberOfStoredBackups);
         return result;
     }
 
@@ -110,10 +110,11 @@ public class XmlFileStorageAdapter implements StorageAdapter, Persister {
 
         Optional<ConfigSnapshot> lastSnapshot = Config.fromXml(storage).getLastSnapshot();
 
-        if (lastSnapshot.isPresent())
+        if (lastSnapshot.isPresent()) {
             return Lists.newArrayList(toConfigSnapshot(lastSnapshot.get()));
-        else
+        } else {
             return Collections.emptyList();
+        }
     }
 
 
index 7c069dab6b0fb04bbd511fefffbfc5ebf3be6879..03b03befe06f3074ad32cc98ceebb89b78e54f94 100644 (file)
@@ -59,7 +59,7 @@ public class ConfigSnapshot {
 
     @Override
     public String toString() {
-        final StringBuffer sb = new StringBuffer("ConfigSnapshot{");
+        final StringBuilder sb = new StringBuilder("ConfigSnapshot{");
         sb.append("configSnapshot='").append(configSnapshot).append('\'');
         sb.append(", capabilities=").append(capabilities);
         sb.append('}');
index 3c544d4e499b28c5da124658da617d4d249af987..3c5f0bdab6b0de6029e0e93084a254b44867eba1 100644 (file)
@@ -12,15 +12,17 @@ import javax.xml.bind.annotation.adapters.XmlAdapter;
 final class StringTrimAdapter extends XmlAdapter<String, String> {
     @Override
     public String unmarshal(String v) throws Exception {
-        if (v == null)
+        if (v == null) {
             return null;
+        }
         return v.trim();
     }
 
     @Override
     public String marshal(String v) throws Exception {
-        if (v == null)
+        if (v == null) {
             return null;
+        }
         return v.trim();
     }
 }
index 559993f2648ec013791bdcf7167e412fe9a69102..11f64e959b450eec42b744c8cfdabd3d91d66594 100644 (file)
@@ -74,16 +74,17 @@ public class ConfigRegistryJMXClient implements ConfigRegistryClient {
      */
     @Deprecated
     public <T> T newMBeanProxy(ObjectName on, Class<T> clazz) {
-        on = translateServiceRefIfPossible(on, clazz, configMBeanServer);
-        return JMX.newMBeanProxy(configMBeanServer, on, clazz);
+        ObjectName onObj = translateServiceRefIfPossible(on, clazz, configMBeanServer);
+        return JMX.newMBeanProxy(configMBeanServer, onObj, clazz);
     }
 
     static  ObjectName translateServiceRefIfPossible(ObjectName on, Class<?> clazz, MBeanServer configMBeanServer) {
-        if (ObjectNameUtil.isServiceReference(on) && clazz.equals(ServiceReferenceMXBean.class) == false) {
-            ServiceReferenceMXBean proxy = JMX.newMXBeanProxy(configMBeanServer, on, ServiceReferenceMXBean.class);
-            on = proxy.getCurrentImplementation();
+        ObjectName onObj = on;
+        if (ObjectNameUtil.isServiceReference(onObj) && clazz.equals(ServiceReferenceMXBean.class) == false) {
+            ServiceReferenceMXBean proxy = JMX.newMXBeanProxy(configMBeanServer, onObj, ServiceReferenceMXBean.class);
+            onObj = proxy.getCurrentImplementation();
         }
-        return on;
+        return onObj;
     }
 
 
index bc188515538485f9a13f87366a281a893a5984ae..20e26f6508513a70c60694586e8351e9e84709bc 100644 (file)
@@ -45,12 +45,13 @@ public class ConfigTransactionJMXClient implements ConfigTransactionClient {
     }
 
     public <T> T newMXBeanProxy(ObjectName on, Class<T> clazz) {
+        ObjectName onName = on;
         // if on is without transaction, add it. Reason is that when using getters on MXBeans the transaction name is stripped
-        on = ObjectNameUtil.withTransactionName(on, getTransactionName());
+        onName = ObjectNameUtil.withTransactionName(onName, getTransactionName());
         // if this is service reference and user requests for implementation, look it up
-        on = ConfigRegistryJMXClient.translateServiceRefIfPossible(on, clazz, configMBeanServer);
-        on = ObjectNameUtil.withTransactionName(on, getTransactionName());
-        return JMX.newMXBeanProxy(configMBeanServer, on, clazz);
+        onName = ConfigRegistryJMXClient.translateServiceRefIfPossible(onName, clazz, configMBeanServer);
+        onName = ObjectNameUtil.withTransactionName(onName, getTransactionName());
+        return JMX.newMXBeanProxy(configMBeanServer, onName, clazz);
     }
 
     /**
@@ -260,9 +261,10 @@ public class ConfigTransactionJMXClient implements ConfigTransactionClient {
 
     @Override
     public void setAttribute(ObjectName on, String attrName, Attribute attribute) {
-        if (ObjectNameUtil.getTransactionName(on) == null)
+        if (ObjectNameUtil.getTransactionName(on) == null) {
             throw new IllegalArgumentException("Not in transaction instance "
                     + on + ", no transaction name present");
+        }
 
         try {
             configMBeanServer.setAttribute(on, attribute);
@@ -274,9 +276,10 @@ public class ConfigTransactionJMXClient implements ConfigTransactionClient {
 
     @Override
     public Attribute getAttribute(ObjectName on, String attrName) {
-        if (ObjectNameUtil.getTransactionName(on) == null)
+        if (ObjectNameUtil.getTransactionName(on) == null) {
             throw new IllegalArgumentException("Not in transaction instance "
                     + on + ", no transaction name present");
+        }
 
         try {
             return new Attribute(attrName, configMBeanServer.getAttribute(on,attrName));
index 9837a04e7f903daf5c16b906d36e46f2f72cc6e7..ff7da5df483556a9eb2a7bdb2e4e89a03bbff0df 100644 (file)
@@ -38,7 +38,7 @@ import com.google.common.collect.Sets;
 public class ContextSetterImpl implements ContextSetter, Closeable {
 
     private final LogbackStatusListener statusListener;
-    private static final org.slf4j.Logger classLogger = LoggerFactory.getLogger(ContextSetterImpl.class);
+    private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(ContextSetterImpl.class);
 
     public ContextSetterImpl(LogbackRuntimeRegistrator rootRuntimeBeanRegistratorWrapper) {
         statusListener = new LogbackStatusListener(rootRuntimeBeanRegistratorWrapper);
@@ -83,11 +83,11 @@ public class ContextSetterImpl implements ContextSetter, Closeable {
         Map<String, Appender<ILoggingEvent>> appendersMap = getAppenders(module, context);
 
         for (LoggerTO logger : module.getLoggerTO()) {
-            classLogger.trace("Setting configuration for logger {}", logger.getLoggerName());
+            LOGGER.trace("Setting configuration for logger {}", logger.getLoggerName());
             final ch.qos.logback.classic.Logger logbackLogger = context.getLogger(logger.getLoggerName());
 
             Optional<Set<Appender<ILoggingEvent>>> appendersBefore = getAppendersBefore(loggersBefore, logbackLogger);
-            classLogger.trace("Logger {}: Appenders registered before: {}", logger.getLoggerName(),
+            LOGGER.trace("Logger {}: Appenders registered before: {}", logger.getLoggerName(),
                     appendersBefore.isPresent() ? appendersBefore.get() : "NO APPENDERS BEFORE");
 
             logbackLogger.setLevel(Level.toLevel(logger.getLevel()));
@@ -103,7 +103,7 @@ public class ContextSetterImpl implements ContextSetter, Closeable {
             for (String appenderName : logger.getAppenders()) {
                 if (appendersMap.containsKey(appenderName)) {
                     logbackLogger.addAppender(appendersMap.get(appenderName));
-                    classLogger.trace("Logger {}: Adding new appender: {}", logger.getLoggerName(), appenderName);
+                    LOGGER.trace("Logger {}: Adding new appender: {}", logger.getLoggerName(), appenderName);
                 } else {
                     throw new IllegalStateException("No appender " + appenderName
                             + " found. This error should have been discovered by validation");
@@ -118,7 +118,7 @@ public class ContextSetterImpl implements ContextSetter, Closeable {
             for (Appender<ILoggingEvent> appenderBefore : appendersBefore.get()) {
                 logbackLogger.detachAppender(appenderBefore);
                 appenderBefore.stop();
-                classLogger.trace("Logger {}: Removing old appender: {}", logger.getLoggerName(),
+                LOGGER.trace("Logger {}: Removing old appender: {}", logger.getLoggerName(),
                         appenderBefore.getName());
             }
             loggersBefore.remove(logbackLogger);
@@ -134,8 +134,9 @@ public class ContextSetterImpl implements ContextSetter, Closeable {
                 appendersBefore.add(appenderIt.next());
             }
             return Optional.of(appendersBefore);
-        } else
+        } else {
             return Optional.absent();
+        }
 
     }
 
index 5a91796ed602d4f239dae51e9ffd14cbd9038f48..b5d0d1b4de0466e1d1c09d55e92644abf6bb4dd7 100644 (file)
@@ -173,10 +173,11 @@ public class LogbackModuleFactory extends
                 context.getLogger(Logger.ROOT_LOGGER_NAME));
         for (org.slf4j.Logger log : loggersToBeAdd) {
             LoggerTO logger = new LoggerTO();
-            if (((Logger) log).getLevel() != null)
+            if (((Logger) log).getLevel() != null) {
                 logger.setLevel(((Logger) log).getLevel().levelStr);
-            else
+            } else {
                 logger.setLevel(((Logger) log).getEffectiveLevel().levelStr);
+            }
             logger.setLoggerName(log.getName());
             Iterator<Appender<ILoggingEvent>> iter = ((Logger) log).iteratorForAppenders();
             while (iter.hasNext()) {
index dd2b504da9a03ab6807efc22adef2c1cf16c990b..cd0f491ebc949c610e925916fc41628eb1a03607 100644 (file)
@@ -41,18 +41,18 @@ import java.util.Map.Entry;
 
 final class CodeWriter {
 
-    private static final Logger logger = LoggerFactory.getLogger(CodeWriter.class);
-    private static final Optional<String> copyright = StringUtil.loadCopyright();
+    private static final Logger LOGGER = LoggerFactory.getLogger(CodeWriter.class);
+    private static final Optional<String> COPYRIGHT = StringUtil.loadCopyright();
 
     public File writeSie(ServiceInterfaceEntry sie, File outputBaseDir) {
         try {
             GeneralInterfaceTemplate generalInterfaceTemplate = TemplateFactory.serviceInterfaceFromSie(sie);
-            GeneratedObject go = new GenericGeneratedObjectFactory().toGeneratedObject(generalInterfaceTemplate, copyright);
+            GeneratedObject go = new GenericGeneratedObjectFactory().toGeneratedObject(generalInterfaceTemplate, COPYRIGHT);
             return go.persist(outputBaseDir).get().getValue();
         } catch (Exception e) {
             String message = "An error occurred during Service interface generating, sie:"
                     + sie.getTypeName() + ", " + sie.getFullyQualifiedName();
-            logger.error(message, e);
+            LOGGER.error(message, e);
             throw new RuntimeException(message, e);
         }
     }
@@ -70,33 +70,33 @@ final class CodeWriter {
             // TOs
             Map<String,GeneralClassTemplate> tosFromMbe = TemplateFactory.tOsFromMbe(mbe);
             for(GeneralClassTemplate template: tosFromMbe.values()) {
-                gos.put(new GenericGeneratedObjectFactory().toGeneratedObject(template, copyright), true);
+                gos.put(new GenericGeneratedObjectFactory().toGeneratedObject(template, COPYRIGHT), true);
             }
 
             // MXBean interface
             GeneralInterfaceTemplate ifcTemplate = TemplateFactory.mXBeanInterfaceTemplateFromMbe(mbe);
-            gos.put(new GenericGeneratedObjectFactory().toGeneratedObject(ifcTemplate, copyright), true);
+            gos.put(new GenericGeneratedObjectFactory().toGeneratedObject(ifcTemplate, COPYRIGHT), true);
 
 
             // generate abstract factory
-            gos.put(new AbsFactoryGeneratedObjectFactory().toGeneratedObject(mbe, copyright), true);
+            gos.put(new AbsFactoryGeneratedObjectFactory().toGeneratedObject(mbe, COPYRIGHT), true);
 
             // generate abstract module
-            gos.put(new AbsModuleGeneratedObjectFactory().toGeneratedObject(mbe, copyright), true);
+            gos.put(new AbsModuleGeneratedObjectFactory().toGeneratedObject(mbe, COPYRIGHT), true);
 
             // generate concrete factory
             StubFactoryTemplate concreteFactory = TemplateFactory.stubFactoryTemplateFromMbe(mbe);
-            gos.put(new GenericGeneratedObjectFactory().toGeneratedObject(concreteFactory, copyright), false);
+            gos.put(new GenericGeneratedObjectFactory().toGeneratedObject(concreteFactory, COPYRIGHT), false);
 
 
             // generate concrete module
 
-            gos.put(new ConcreteModuleGeneratedObjectFactory().toGeneratedObject(mbe, copyright, Optional.<String>absent()), false);
+            gos.put(new ConcreteModuleGeneratedObjectFactory().toGeneratedObject(mbe, COPYRIGHT, Optional.<String>absent()), false);
 
             // write runtime bean MXBeans and registrators
             List<FtlTemplate> allFtlFiles = getRuntimeBeanFtlTemplates(mbe.getRuntimeBeans());
             for(FtlTemplate template: allFtlFiles) {
-                gos.put(new GenericGeneratedObjectFactory().toGeneratedObject(template, copyright), true);
+                gos.put(new GenericGeneratedObjectFactory().toGeneratedObject(template, COPYRIGHT), true);
             }
 
             generatedFiles.addAll(persistGeneratedObjects(targetBaseDir, mainBaseDir, gos));
@@ -113,7 +113,7 @@ final class CodeWriter {
         } catch (Exception e) {
             String message = "An error occurred during Module generating, mbe:"
                     + mbe.getJavaNamePrefix();
-            logger.error(message, e);
+            LOGGER.error(message, e);
             throw new RuntimeException(message, e);
         }
     }
index 1b8905b9871c0a1334ebacbc28a1f6dd52d41492..c8356274f8144095581e504e8b45680051be319d 100644 (file)
@@ -54,7 +54,7 @@ public class JMXGenerator implements CodeGenerator {
 
     private PackageTranslator packageTranslator;
     private final CodeWriter codeWriter;
-    private static final Logger logger = LoggerFactory
+    private static final Logger LOGGER = LoggerFactory
             .getLogger(JMXGenerator.class);
     private Map<String, String> namespaceToPackageMapping;
     private File resourceBaseDir;
@@ -83,8 +83,9 @@ public class JMXGenerator implements CodeGenerator {
 
         packageTranslator = new PackageTranslator(namespaceToPackageMapping);
 
-        if (!outputBaseDir.exists())
+        if (!outputBaseDir.exists()) {
             outputBaseDir.mkdirs();
+        }
 
         GeneratedFilesTracker generatedFiles = new GeneratedFilesTracker();
         // create SIE structure qNamesToSIEs
@@ -127,7 +128,7 @@ public class JMXGenerator implements CodeGenerator {
         Preconditions.checkNotNull(resourceBaseDir,
                 "resource base dir attribute was null");
 
-        StringBuffer fullyQualifiedNamesOfFactories = new StringBuffer();
+        StringBuilder fullyQualifiedNamesOfFactories = new StringBuilder();
         // create MBEs
         for (Module module : yangModulesInCurrentMavenModule) {
             String packageName = packageTranslator.getPackageName(module);
@@ -166,7 +167,7 @@ public class JMXGenerator implements CodeGenerator {
                         fullyQualifiedNamesOfFactories.toString());
             } catch (IOException e) {
                 String message = "Cannot write to " + serviceLoaderFile;
-                logger.error(message);
+                LOGGER.error(message);
                 throw new RuntimeException(message, e);
             }
         }
@@ -184,10 +185,11 @@ public class JMXGenerator implements CodeGenerator {
 
     @Override
     public void setAdditionalConfig(Map<String, String> additionalCfg) {
-        if (logger != null)
-            logger.debug(getClass().getCanonicalName(),
+        if (LOGGER != null) {
+            LOGGER.debug(getClass().getCanonicalName(),
                     ": Additional configuration received: ",
                     additionalCfg.toString());
+        }
         this.namespaceToPackageMapping = extractNamespaceMapping(additionalCfg);
         this.generateModuleFactoryFile = extractModuleFactoryBoolean(additionalCfg);
     }
@@ -195,10 +197,12 @@ public class JMXGenerator implements CodeGenerator {
     private boolean extractModuleFactoryBoolean(
             Map<String, String> additionalCfg) {
         String bool = additionalCfg.get(MODULE_FACTORY_FILE_BOOLEAN);
-        if (bool == null)
+        if (bool == null) {
             return true;
-        if (bool.equals("false"))
+        }
+        if ("false".equals(bool)) {
             return false;
+        }
         return true;
     }
 
@@ -250,8 +254,8 @@ public class JMXGenerator implements CodeGenerator {
     public void setMavenProject(MavenProject project) {
         this.projectBaseDir = project.getBasedir();
 
-        if (logger != null)
-            logger.debug(getClass().getCanonicalName(), " project base dir: ",
+        if (LOGGER != null)
+            LOGGER.debug(getClass().getCanonicalName(), " project base dir: ",
                     projectBaseDir);
     }
 
@@ -268,7 +272,7 @@ public class JMXGenerator implements CodeGenerator {
                     }
                 }
                 if (undeletedFiles.isEmpty() == false) {
-                    logger.error(
+                    LOGGER.error(
                             "Illegal state occurred: Unable to delete already generated files, undeleted files: {}",
                             undeletedFiles);
                 }
index c3e51d6550e50344ed8fc1c9ad5c46f6282af7cc..c3a00b93da1b4d88a763ba07ee726a8b8966d382 100644 (file)
@@ -19,14 +19,14 @@ import java.util.List;
 
 public class AbstractFactoryTemplate extends GeneralClassTemplate {
 
-    private static final List<String> implementedIfcs = Lists
+    private static final List<String> IMPLEMENTED_IFCS = Lists
             .newArrayList(ModuleFactory.class.getCanonicalName());
 
     public AbstractFactoryTemplate(Header header, String packageName,
                                    String abstractFactoryName,
                                    List<Field> fields) {
         super(header, packageName, abstractFactoryName, Collections
-                .<String> emptyList(), implementedIfcs, fields, Collections
+                .<String> emptyList(), IMPLEMENTED_IFCS, fields, Collections
                 .<MethodDefinition> emptyList(), true, false, Collections
                 .<Constructor> emptyList());
     }
index d07edae14ee42283827ddf8c52cb6ce9d92aba44..aa696450a94e8a5971fd96c58bcbb6e17edfaab9 100644 (file)
@@ -108,7 +108,7 @@ public class RuntimeRegistratorFtlTemplate extends GeneralClassTemplate {
                     .getFullyQualifiedName(rootRB.getPackageName(), rootRB.getJavaNameOfRuntimeMXBean());
             String childRegistratorFQN = rootFtlFile.getFullyQualifiedName();
             Field rbParameter = new Field(fullyQualifiedNameOfMXBean, "rb");
-            StringBuffer registerBody = new StringBuffer();
+            StringBuilder registerBody = new StringBuilder();
             registerBody.append(format("%s %s = this.%s.registerRoot(%s);\n",
                     HierarchicalRuntimeBeanRegistration.class
                             .getCanonicalName(), hierachchicalRegistration
@@ -200,12 +200,12 @@ public class RuntimeRegistratorFtlTemplate extends GeneralClassTemplate {
                 unorderedResult.put(entry.getKey(), entry.getValue());
             }
 
-            if (childRegistratorMap.size() > 0) {
+            if (!childRegistratorMap.isEmpty()) {
                 // first entry is the direct descendant according to the create
                 // contract
                 RuntimeRegistratorFtlTemplate childRegistrator = childRegistratorMap
                         .values().iterator().next();
-                StringBuffer body = new StringBuffer();
+                StringBuilder body = new StringBuilder();
                 String key, value;
                 key = child.getJavaNamePrefix();
                 body.append(format(
index 7b7aab85597eafbd4fcb113abfea20dfe19c49d1..f8f5cd6742a1182e47c7194fb3ec215316ce7ca5 100644 (file)
@@ -113,7 +113,7 @@ public class TemplateFactory {
     static String serializeType(Type type, boolean addWildcards) {
         if (type instanceof ParameterizedType){
             ParameterizedType parameterizedType = (ParameterizedType) type;
-            StringBuffer sb = new StringBuffer();
+            StringBuilder sb = new StringBuilder();
             sb.append(parameterizedType.getRawType().getFullyQualifiedName());
             sb.append(addWildcards ? "<? extends " : "<");
             boolean first = true;
@@ -282,12 +282,15 @@ public class TemplateFactory {
         for (Rpc rpc : rbe.getRpcs()) {
             AttributeIfc returnType = rpc.getReturnType();
 
-            if (returnType == VoidAttribute.getInstance())
+            if (returnType == VoidAttribute.getInstance()) {
                 continue;
-            if (returnType instanceof JavaAttribute)
+            }
+            if (returnType instanceof JavaAttribute) {
                 continue;
-            if (returnType instanceof ListAttribute && returnType.getOpenType() instanceof SimpleType)
+            }
+            if (returnType instanceof ListAttribute && returnType.getOpenType() instanceof SimpleType) {
                 continue;
+            }
 
             Preconditions.checkState(yangPropertiesToTypesMap.containsKey(returnType.getAttributeYangName()) == false,
                     "Duplicate TO %s for %s", returnType.getAttributeYangName(), rbe);
@@ -449,7 +452,6 @@ public class TemplateFactory {
                 String returnType;
                 AttributeIfc attributeIfc = attrEntry.getValue();
 
-                boolean isIdentityRef = false;
                 if (attributeIfc instanceof TypedAttribute) {
                     TypedAttribute typedAttribute = (TypedAttribute) attributeIfc;
                     returnType = serializeType(typedAttribute.getType());
index 775fa9fc20d97b10a48859703a4572f03b65d2ca..8cc0ffa165a8d63f387dcb1dd9812b0ec0764124 100644 (file)
@@ -11,6 +11,9 @@ import org.opendaylight.yangtools.yang.common.QName;
 
 public class ConfigConstants {
 
+    private ConfigConstants() {
+    }
+
     public static final String CONFIG_NAMESPACE = "urn:opendaylight:params:xml:ns:yang:controller:config";
 
     public static final String CONFIG_MODULE = "config";
index e9f0ac817675d90a9c9257456d0f9c03c7106719..f99d378b6f3e9175be67fed5284827d0ff50b4db 100644 (file)
@@ -93,22 +93,22 @@ final class ModuleMXBeanEntryBuilder {
         return this;
     }
 
-    private static final Logger logger = LoggerFactory
+    private static final Logger LOGGER = LoggerFactory
             .getLogger(ModuleMXBeanEntryBuilder.class);
 
     // TODO: the XPath should be parsed by code generator IMO
     private static final String MAGIC_STRING = "MAGIC_STRING";
     private static final String MODULE_CONDITION_XPATH_TEMPLATE = "^/MAGIC_STRING:modules/MAGIC_STRING:module/MAGIC_STRING:type\\s*=\\s*['\"](.+)['\"]$";
-    private static final SchemaPath expectedConfigurationAugmentationSchemaPath = SchemaPath.create(true,
+    private static final SchemaPath EXPECTED_CONFIGURATION_AUGMENTATION_SCHEMA_PATH = SchemaPath.create(true,
             createConfigQName("modules"), createConfigQName("module"), createConfigQName("configuration"));
-    private static final SchemaPath expectedStateAugmentationSchemaPath = SchemaPath.create(true,
+    private static final SchemaPath EXPECTED_STATE_AUGMENTATION_SCHEMA_PATH = SchemaPath.create(true,
             createConfigQName("modules"), createConfigQName("module"), createConfigQName("state"));
     private static final Pattern PREFIX_COLON_LOCAL_NAME = Pattern
             .compile("^(.+):(.+)$");
 
 
     public Map<String, ModuleMXBeanEntry> build() {
-        logger.debug("Generating ModuleMXBeans of {} to package {}",
+        LOGGER.debug("Generating ModuleMXBeans of {} to package {}",
                 currentModule.getNamespace(), packageName);
 
         String configModulePrefix;
@@ -146,7 +146,7 @@ final class ModuleMXBeanEntryBuilder {
         checkAttributeNamesUniqueness(uniqueGeneratedClassesNames, result);
         checkUnaugumentedIdentities(unaugmentedModuleIdentities);
 
-        logger.debug("Number of ModuleMXBeans to be generated: {}", result.size());
+        LOGGER.debug("Number of ModuleMXBeans to be generated: {}", result.size());
 
         return result;
     }
@@ -166,7 +166,7 @@ final class ModuleMXBeanEntryBuilder {
 
     private static void checkUnaugumentedIdentities(final Map<String, IdentitySchemaNode> unaugmentedModuleIdentities) {
         if (unaugmentedModuleIdentities.size() > 0) {
-            logger.warn("Augmentation not found for all currentModule identities: {}",
+            LOGGER.warn("Augmentation not found for all currentModule identities: {}",
                     unaugmentedModuleIdentities.keySet());
         }
     }
@@ -190,7 +190,7 @@ final class ModuleMXBeanEntryBuilder {
                             + identityLocalName);
                 } else {
                     moduleIdentities.put(identityLocalName, id);
-                    logger.debug("Found identity {}", identityLocalName);
+                    LOGGER.debug("Found identity {}", identityLocalName);
                 }
                 // validation check on unknown schema nodes
                 boolean providedServiceWasSet = false;
@@ -270,13 +270,13 @@ final class ModuleMXBeanEntryBuilder {
 
         HAS_CHILDREN_AND_QNAME dataNodeContainer = getDataNodeContainer(choiceCaseNode);
 
-        if (expectedConfigurationAugmentationSchemaPath.equals(augmentation.getTargetPath())) {
-            logger.debug("Parsing configuration of {}", moduleLocalNameFromXPath);
+        if (EXPECTED_CONFIGURATION_AUGMENTATION_SCHEMA_PATH.equals(augmentation.getTargetPath())) {
+            LOGGER.debug("Parsing configuration of {}", moduleLocalNameFromXPath);
             yangToAttributes = fillConfiguration(dataNodeContainer, currentModule, typeProviderWrapper, qNamesToSIEs,
                     schemaContext, packageName);
             checkUniqueAttributesWithGeneratedClass(uniqueGeneratedClassesNames, when.getQName(), yangToAttributes);
-        } else if (expectedStateAugmentationSchemaPath.equals(augmentation.getTargetPath())) {
-            logger.debug("Parsing state of {}", moduleLocalNameFromXPath);
+        } else if (EXPECTED_STATE_AUGMENTATION_SCHEMA_PATH.equals(augmentation.getTargetPath())) {
+            LOGGER.debug("Parsing state of {}", moduleLocalNameFromXPath);
             try {
                 runtimeBeans = fillRuntimeBeans(dataNodeContainer, currentModule, typeProviderWrapper, packageName,
                         moduleLocalNameFromXPath, javaNamePrefix);
index ccd701d1fb36a2bba58093999a21aa23c7ac5c08..10267b28e7b6a729b8125c6564a5bf14636da318 100644 (file)
@@ -12,6 +12,9 @@ import org.opendaylight.yangtools.yang.model.api.Module;
 
 public class ModuleUtil {
 
+    private ModuleUtil() {
+    }
+
     public static QName getQName(final Module currentModule) {
         return QName.create(currentModule.getNamespace(), currentModule.getRevision(), currentModule.getName());
     }
index a6a1ac7dc391b05267e71e1575d5f4d7d6cd5396..a7f6f2f221e295ebbf4b17b0ea7c869f1265ace8 100644 (file)
@@ -58,19 +58,20 @@ public class PackageTranslator {
 
     // TODO add to PackageTranslator
     private static String sanitizePackage(String namespace) {
-        namespace = namespace.replace("://", ".");
-        namespace = namespace.replace("/", ".");
-        namespace = namespace.replace(":", ".");
-        namespace = namespace.replace("-", "_");
-        namespace = namespace.replace("@", ".");
-        namespace = namespace.replace("$", ".");
-        namespace = namespace.replace("#", ".");
-        namespace = namespace.replace("'", ".");
-        namespace = namespace.replace("*", ".");
-        namespace = namespace.replace("+", ".");
-        namespace = namespace.replace(",", ".");
-        namespace = namespace.replace(";", ".");
-        namespace = namespace.replace("=", ".");
-        return namespace;
+        String newNamespace = namespace;
+        newNamespace = newNamespace.replace("://", ".");
+        newNamespace = newNamespace.replace("/", ".");
+        newNamespace = newNamespace.replace(":", ".");
+        newNamespace = newNamespace.replace("-", "_");
+        newNamespace = newNamespace.replace("@", ".");
+        newNamespace = newNamespace.replace("$", ".");
+        newNamespace = newNamespace.replace("#", ".");
+        newNamespace = newNamespace.replace("'", ".");
+        newNamespace = newNamespace.replace("*", ".");
+        newNamespace = newNamespace.replace("+", ".");
+        newNamespace = newNamespace.replace(",", ".");
+        newNamespace = newNamespace.replace(";", ".");
+        newNamespace = newNamespace.replace("=", ".");
+        return newNamespace;
     }
 }
index 67f624175b00aacff88369aa8fce5fe00ce5a961..aec41152de5fda3138430091e41344bc059feeaf 100644 (file)
@@ -217,8 +217,6 @@ public class RuntimeBeanEntry {
             final Map<QName, Set<RpcDefinition>> identitiesToRpcs) {
 
         List<AttributeIfc> attributes = Lists.newArrayList();
-        // List<JavaAttribute> javaAttributes = new ArrayList<>();
-        // List<TOAttribute> toAttributes = new ArrayList<>();
         List<RuntimeBeanEntry> runtimeBeanEntries = new ArrayList<>();
         for (DataSchemaNode child : subtree.getChildNodes()) {
             // child leaves can be java attributes, TO attributes, or child
@@ -278,7 +276,7 @@ public class RuntimeBeanEntry {
                             .findJavaParameter(rpcDefinition);
                     AttributeIfc returnType;
                     if (rpcDefinition.getOutput() == null
-                            || rpcDefinition.getOutput().getChildNodes().size() == 0) {
+                            || rpcDefinition.getOutput().getChildNodes().isEmpty()) {
                         returnType = VoidAttribute.getInstance();
                     } else if (rpcDefinition.getOutput().getChildNodes().size() == 1) {
                         DataSchemaNode returnDSN = rpcDefinition.getOutput()
@@ -366,7 +364,7 @@ public class RuntimeBeanEntry {
                 currentModule, identitiesToRpcs);
 
         Optional<String> keyYangName;
-        if (listSchemaNode.getKeyDefinition().size() == 0) {
+        if (listSchemaNode.getKeyDefinition().isEmpty()) {
             keyYangName = Optional.absent();
         } else if (listSchemaNode.getKeyDefinition().size() == 1) {
             // key must be either null or one of supported key types
index ef40d9515b42c75ad3b6d6e56456ea83a1912688..ee02b303e0b2aa1778d2b45cffd421946411ae4f 100644 (file)
@@ -46,7 +46,7 @@ import static org.opendaylight.controller.config.yangjmxgenerator.ConfigConstant
  * </p>
  */
 public class ServiceInterfaceEntry extends AbstractEntry {
-    private static final Logger logger = LoggerFactory
+    private static final Logger LOGGER = LoggerFactory
             .getLogger(ServiceInterfaceEntry.class);
 
     private static final String CLASS_NAME_SUFFIX = "ServiceInterface";
@@ -121,16 +121,16 @@ public class ServiceInterfaceEntry extends AbstractEntry {
      */
     public static Map<QName, ServiceInterfaceEntry> create(Module currentModule,
             String packageName,Map<IdentitySchemaNode, ServiceInterfaceEntry> definedSEItracker) {
-        logger.debug("Generating ServiceInterfaces from {} to package {}",
+        LOGGER.debug("Generating ServiceInterfaces from {} to package {}",
                 currentModule.getNamespace(), packageName);
 
         Map<IdentitySchemaNode, ServiceInterfaceEntry> identitiesToSIs = new HashMap<>();
         Set<IdentitySchemaNode> notVisited = new HashSet<>(
                 currentModule.getIdentities());
         int lastSize = notVisited.size() + 1;
-        while (notVisited.size() > 0) {
+        while (!notVisited.isEmpty()) {
             if (notVisited.size() == lastSize) {
-                logger.debug(
+                LOGGER.debug(
                         "Following identities will be ignored while generating ServiceInterfaces, as they are not derived from {} : {}",
                         SERVICE_TYPE_Q_NAME, notVisited);
                 break;
@@ -175,7 +175,7 @@ public class ServiceInterfaceEntry extends AbstractEntry {
         for (ServiceInterfaceEntry sie : identitiesToSIs.values()) {
             resultMap.put(sie.getQName(), sie);
         }
-        logger.debug("Number of ServiceInterfaces to be generated: {}",
+        LOGGER.debug("Number of ServiceInterfaces to be generated: {}",
                 resultMap.size());
         return resultMap;
     }
@@ -198,25 +198,33 @@ public class ServiceInterfaceEntry extends AbstractEntry {
 
     @Override
     public boolean equals(Object o) {
-        if (this == o)
+        if (this == o) {
             return true;
-        if (o == null || getClass() != o.getClass())
+        }
+        if (o == null || getClass() != o.getClass()) {
             return false;
+        }
 
         ServiceInterfaceEntry that = (ServiceInterfaceEntry) o;
 
-        if (!maybeBaseCache.equals(that.maybeBaseCache))
+        if (!maybeBaseCache.equals(that.maybeBaseCache)) {
             return false;
-        if (!nullableDescription.equals(that.nullableDescription))
+        }
+        if (!nullableDescription.equals(that.nullableDescription)) {
             return false;
-        if (!exportedOsgiClassName.equals(that.exportedOsgiClassName))
+        }
+        if (!exportedOsgiClassName.equals(that.exportedOsgiClassName)) {
             return false;
-        if (!qName.equals(that.qName))
+        }
+        if (!qName.equals(that.qName)) {
             return false;
-        if (!packageName.equals(that.packageName))
+        }
+        if (!packageName.equals(that.packageName)) {
             return false;
-        if (!typeName.equals(that.typeName))
+        }
+        if (!typeName.equals(that.typeName)) {
             return false;
+        }
 
         return true;
     }
index 3c8c8aa2f4190af52f4484e1bda534c73d74eabb..ac1992932fe6c348920470b0c9e93004a49c5bf9 100644 (file)
@@ -71,9 +71,10 @@ public class TypeProviderWrapper {
         try {
             javaType = typeProvider.javaTypeForSchemaDefinitionType(
                     type, leaf);
-            if (javaType == null)
+            if (javaType == null) {
                 throw new IllegalArgumentException("Unknown type received for "
                         + leaf.toString());
+            }
         } catch (IllegalArgumentException e) {
             throw new IllegalArgumentException("Error while resolving type of "
                     + leaf, e);
@@ -87,9 +88,10 @@ public class TypeProviderWrapper {
         try {
             javaType = typeProvider.javaTypeForSchemaDefinitionType(
                     leaf.getType(), leaf);
-            if (javaType == null)
+            if (javaType == null) {
                 throw new IllegalArgumentException(
                         "Unknown type received for  " + leaf.toString());
+            }
         } catch (IllegalArgumentException e) {
             throw new IllegalArgumentException("Error while resolving type of "
                     + leaf, e);
index edfb4c59afe2c223685adeb487172ea85640a574..d9a6dd045214c4f01271703a8a3c4942cae33852 100644 (file)
@@ -33,17 +33,20 @@ public abstract class AbstractAttribute implements AttributeIfc {
 
     @Override
     public boolean equals(Object o) {
-        if (this == o)
+        if (this == o) {
             return true;
-        if (!(o instanceof AbstractAttribute))
+        }
+        if (!(o instanceof AbstractAttribute)) {
             return false;
+        }
 
         AbstractAttribute that = (AbstractAttribute) o;
 
         if (attributeYangName != null ? !attributeYangName
                 .equals(that.attributeYangName)
-                : that.attributeYangName != null)
+                : that.attributeYangName != null) {
             return false;
+        }
 
         return true;
     }
index eb1c9e41a6baf789b51a63a575e39cc9a16723ba..205ba893c4d7a4003875e08d7ab9a3aa2eb909a2 100644 (file)
@@ -40,25 +40,31 @@ public abstract class AbstractDependencyAttribute extends AbstractAttribute  imp
 
     @Override
     public boolean equals(Object o) {
-        if (this == o)
+        if (this == o) {
             return true;
-        if (o == null || getClass() != o.getClass())
+        }
+        if (o == null || getClass() != o.getClass()) {
             return false;
-        if (!super.equals(o))
+        }
+        if (!super.equals(o)) {
             return false;
+        }
 
         AbstractDependencyAttribute that = (AbstractDependencyAttribute) o;
 
         if (dependency != null ? !dependency.equals(that.dependency)
-                : that.dependency != null)
+                : that.dependency != null) {
             return false;
+        }
         if (nullableDefault != null ? !nullableDefault
-                .equals(that.nullableDefault) : that.nullableDefault != null)
+                .equals(that.nullableDefault) : that.nullableDefault != null) {
             return false;
+        }
         if (nullableDescription != null ? !nullableDescription
                 .equals(that.nullableDescription)
-                : that.nullableDescription != null)
+                : that.nullableDescription != null) {
             return false;
+        }
 
         return true;
     }
index fac4d5743229501fd7827269a8c810ac6b6f54a1..8d3139999e64db347e927dfa6dfc0e083c815a55 100644 (file)
@@ -96,24 +96,30 @@ public class JavaAttribute extends AbstractAttribute implements TypedAttribute {
 
     @Override
     public boolean equals(Object o) {
-        if (this == o)
+        if (this == o) {
             return true;
-        if (o == null || getClass() != o.getClass())
+        }
+        if (o == null || getClass() != o.getClass()) {
             return false;
-        if (!super.equals(o))
+        }
+        if (!super.equals(o)) {
             return false;
+        }
 
         JavaAttribute that = (JavaAttribute) o;
 
         if (nullableDefault != null ? !nullableDefault
-                .equals(that.nullableDefault) : that.nullableDefault != null)
+                .equals(that.nullableDefault) : that.nullableDefault != null) {
             return false;
+        }
         if (nullableDescription != null ? !nullableDescription
                 .equals(that.nullableDescription)
-                : that.nullableDescription != null)
+                : that.nullableDescription != null) {
             return false;
-        if (type != null ? !type.equals(that.type) : that.type != null)
+        }
+        if (type != null ? !type.equals(that.type) : that.type != null) {
             return false;
+        }
 
         return true;
     }
index 73b557e291c03385823fb214fb0a96054d2b6610..bb71f9dbc733da09c17e6be379bde458a0df7591 100644 (file)
@@ -82,22 +82,27 @@ public class ListAttribute extends AbstractAttribute implements TypedAttribute {
 
     @Override
     public boolean equals(Object o) {
-        if (this == o)
+        if (this == o) {
             return true;
-        if (o == null || getClass() != o.getClass())
+        }
+        if (o == null || getClass() != o.getClass()) {
             return false;
-        if (!super.equals(o))
+        }
+        if (!super.equals(o)) {
             return false;
+        }
 
         ListAttribute that = (ListAttribute) o;
 
         if (nullableDefault != null ? !nullableDefault
-                .equals(that.nullableDefault) : that.nullableDefault != null)
+                .equals(that.nullableDefault) : that.nullableDefault != null) {
             return false;
+        }
         if (nullableDescription != null ? !nullableDescription
                 .equals(that.nullableDescription)
-                : that.nullableDescription != null)
+                : that.nullableDescription != null) {
             return false;
+        }
 
         return true;
     }
index f4bd979faca43fa5f4bdce943ceeb389ca07b42b..9b5530175cf3e0d7165311d2d77d7f43c82681a8 100644 (file)
@@ -19,6 +19,9 @@ import java.util.Map;
 
 public class SimpleTypeResolver {
 
+    private SimpleTypeResolver() {
+    }
+
     public static SimpleType<?> getSimpleType(Type type) {
         SimpleType<?> expectedSimpleType = JAVA_TYPE_TO_SIMPLE_TYPE.get(type
                 .getFullyQualifiedName());
index cbeb5c3b297415bacf1a74596abbbf8d4fb9d207..e563da1328a210f82b44f498b08fd9c73348cfd3 100644 (file)
@@ -73,18 +73,19 @@ public class TOAttribute extends AbstractAttribute implements TypedAttribute {
             TypeProviderWrapper typeProviderWrapper, String packageName) {
         Class<? extends DataSchemaNode> type = isAllowedType(dataSchemaNode);
 
-        if (type.equals(LeafSchemaNode.class))
+        if (type.equals(LeafSchemaNode.class)) {
             return new JavaAttribute((LeafSchemaNode) dataSchemaNode,
                     typeProviderWrapper);
-        else if (type.equals(ListSchemaNode.class))
+        } else if (type.equals(ListSchemaNode.class)) {
             return ListAttribute.create((ListSchemaNode) dataSchemaNode,
                     typeProviderWrapper, packageName);
-        else if (type.equals(LeafListSchemaNode.class))
+        } else if (type.equals(LeafListSchemaNode.class)) {
             return ListAttribute.create((LeafListSchemaNode) dataSchemaNode,
                     typeProviderWrapper);
-        else if (type.equals(ContainerSchemaNode.class))
+        } else if (type.equals(ContainerSchemaNode.class)) {
             return TOAttribute.create((ContainerSchemaNode) dataSchemaNode,
                     typeProviderWrapper, packageName);
+        }
 
         throw new IllegalStateException("This should never happen");
     }
@@ -92,8 +93,9 @@ public class TOAttribute extends AbstractAttribute implements TypedAttribute {
     private static Class<? extends DataSchemaNode> isAllowedType(
             DataSchemaNode dataSchemaNode) {
         for (Class<? extends DataSchemaNode> allowedType : ALLOWED_CHILDREN) {
-            if (allowedType.isAssignableFrom(dataSchemaNode.getClass()) == true)
+            if (allowedType.isAssignableFrom(dataSchemaNode.getClass()) == true) {
                 return allowedType;
+            }
         }
         throw new IllegalArgumentException("Illegal child node for TO: "
                 + dataSchemaNode.getClass() + " allowed node types: "
@@ -156,26 +158,32 @@ public class TOAttribute extends AbstractAttribute implements TypedAttribute {
 
     @Override
     public boolean equals(Object o) {
-        if (this == o)
+        if (this == o) {
             return true;
-        if (o == null || getClass() != o.getClass())
+        }
+        if (o == null || getClass() != o.getClass()) {
             return false;
-        if (!super.equals(o))
+        }
+        if (!super.equals(o)) {
             return false;
+        }
 
         TOAttribute that = (TOAttribute) o;
 
         if (nullableDefault != null ? !nullableDefault
-                .equals(that.nullableDefault) : that.nullableDefault != null)
+                .equals(that.nullableDefault) : that.nullableDefault != null) {
             return false;
+        }
         if (nullableDescription != null ? !nullableDescription
                 .equals(that.nullableDescription)
-                : that.nullableDescription != null)
+                : that.nullableDescription != null) {
             return false;
+        }
         if (yangNameToAttributeMap != null ? !yangNameToAttributeMap
                 .equals(that.yangNameToAttributeMap)
-                : that.yangNameToAttributeMap != null)
+                : that.yangNameToAttributeMap != null) {
             return false;
+        }
 
         return true;
     }
index 30c7919c1a3cd89090ab168d8b848cb8e54b2af9..16c4bd1ec5ba76eaa3f5f19cdf3353cc94d153fe 100644 (file)
@@ -13,17 +13,19 @@ import java.util.Date;
 
 final class Util {
 
+    private Util() {
+    }
     /**
      * Used for date <-> xml serialization
      */
-    private static final SimpleDateFormat dateFormat = new SimpleDateFormat(
+    private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat(
             "yyyy-MM-dd");
 
     public static String writeDate(Date date) {
-        return dateFormat.format(date);
+        return DATE_FORMAT.format(date);
     }
 
     public static Date readDate(String s) throws ParseException {
-        return dateFormat.parse(s);
+        return DATE_FORMAT.parse(s);
     }
 }
index 50b4485e01e947c2e9d6156c097b5d37d31e6fcc..966aff96a050ecc2ba0e48f1d6a27736ddd861d4 100644 (file)
@@ -8,6 +8,10 @@
 package org.opendaylight.controller.config.yangjmxgenerator.plugin.util;
 
 public class FullyQualifiedNameHelper {
+
+    private FullyQualifiedNameHelper() {
+    }
+
     public static String getFullyQualifiedName(String packageName,
             String className) {
         if (packageName.isEmpty())