Remove yang-test
[controller.git] / opendaylight / config / config-persister-impl / src / main / java / org / opendaylight / controller / config / persist / impl / PersisterAggregator.java
index f60eecee79f2bdb0e773d5a23a3cbbcfab875f80..8926b4ce619373b57cca3e6e5ded9d9f697a942d 100644 (file)
@@ -63,7 +63,7 @@ public final class PersisterAggregator implements Persister {
         private final Persister storage;
         private final boolean readOnly;
 
-        public PersisterWithConfiguration(Persister storage, boolean readOnly) {
+        public PersisterWithConfiguration(final Persister storage, final boolean readOnly) {
             this.storage = storage;
             this.readOnly = readOnly;
         }
@@ -87,12 +87,21 @@ public final class PersisterAggregator implements Persister {
         }
     }
 
+    /**
+     * Persisters ordered by 'netconf.config.persister' property.
+     */
+    private final List<PersisterWithConfiguration> persisterWithConfigurations;
+
+    public PersisterAggregator(final List<PersisterWithConfiguration> persisterWithConfigurations) {
+        this.persisterWithConfigurations = persisterWithConfigurations;
+    }
+
     private static PersisterWithConfiguration loadConfiguration(final String index, final PropertiesProvider propertiesProvider) {
 
         String classKey = index + "." + ConfigPersisterActivator.STORAGE_ADAPTER_CLASS_PROP_SUFFIX;
         String storageAdapterClass = propertiesProvider.getProperty(classKey);
         StorageAdapter storageAdapter;
-        if (storageAdapterClass == null || storageAdapterClass.equals("")) {
+        if (storageAdapterClass == null || storageAdapterClass.isEmpty()) {
             throw new IllegalStateException("No persister is defined in " +
                     propertiesProvider.getFullKeyForReporting(classKey)
                     + " property. Persister is not operational");
@@ -106,11 +115,8 @@ public final class PersisterAggregator implements Persister {
             }
             storageAdapter = StorageAdapter.class.cast(clazz.newInstance());
 
-            boolean readOnly = false;
             String readOnlyProperty = propertiesProvider.getProperty(index + "." + "readonly");
-            if (readOnlyProperty != null && readOnlyProperty.equals("true")) {
-                readOnly = true;
-            }
+            boolean readOnly = Boolean.parseBoolean(readOnlyProperty);
 
             PropertiesProviderAdapterImpl innerProvider = new PropertiesProviderAdapterImpl(propertiesProvider, index);
             Persister storage = storageAdapter.instantiate(innerProvider);
@@ -120,17 +126,7 @@ public final class PersisterAggregator implements Persister {
         }
     }
 
-    /**
-     * Persisters ordered by 'netconf.config.persister' property.
-     */
-    private final List<PersisterWithConfiguration> persisterWithConfigurations;
-
-    public PersisterAggregator(List<PersisterWithConfiguration> persisterWithConfigurations) {
-        this.persisterWithConfigurations = persisterWithConfigurations;
-
-    }
-
-    public static PersisterAggregator createFromProperties(PropertiesProvider propertiesProvider) {
+    public static PersisterAggregator createFromProperties(final PropertiesProvider propertiesProvider) {
         List<PersisterWithConfiguration> persisterWithConfigurations = new ArrayList<>();
         String prefixes = propertiesProvider.getProperty("active");
         if (prefixes!=null && !prefixes.isEmpty()) {
@@ -144,7 +140,7 @@ public final class PersisterAggregator implements Persister {
     }
 
     @Override
-    public void persistConfig(ConfigSnapshotHolder holder) throws IOException {
+    public void persistConfig(final ConfigSnapshotHolder holder) throws IOException {
         for (PersisterWithConfiguration persisterWithConfiguration: persisterWithConfigurations){
             if (!persisterWithConfiguration.readOnly){
                 LOG.debug("Calling {}.persistConfig", persisterWithConfiguration.getStorage());
@@ -165,7 +161,7 @@ public final class PersisterAggregator implements Persister {
             List<ConfigSnapshotHolder> configs = null;
             try {
                 configs = persisterWithConfiguration.storage.loadLastConfigs();
-            } catch (IOException e) {
+            } catch (final IOException e) {
                 throw new RuntimeException("Error while calling loadLastConfig on " +  persisterWithConfiguration, e);
             }
             if (!configs.isEmpty()) {
@@ -189,7 +185,7 @@ public final class PersisterAggregator implements Persister {
         for (PersisterWithConfiguration persisterWithConfiguration: persisterWithConfigurations){
             try{
                 persisterWithConfiguration.storage.close();
-            }catch(RuntimeException e) {
+            }catch(final RuntimeException e) {
                 LOG.error("Error while closing {}", persisterWithConfiguration.storage, e);
                 if (lastException == null){
                     lastException = e;