config-persister-file-xml-adapter: final parameters 66/56966/2
authorStephen Kitt <skitt@redhat.com>
Fri, 12 May 2017 12:12:11 +0000 (14:12 +0200)
committerTom Pantelis <tompantelis@gmail.com>
Mon, 15 May 2017 11:52:02 +0000 (11:52 +0000)
This automatically-generated patch flags all appropriate parameters as
final (including caught exceptions).

Change-Id: Ib4cdd95a3c54341995c1d40d9b9c45310f3153ab
Signed-off-by: Stephen Kitt <skitt@redhat.com>
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/Config.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/PersistException.java
opendaylight/config/config-persister-file-xml-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/file/xml/model/SnapshotHandler.java
opendaylight/config/config-persister-file-xml-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/file/xml/model/StringTrimAdapter.java

index c81aa9bec5398a4ed20259cc240fda14075eac81..7ad073415933f9c19be3d13b136dc817e8fd1da8 100644 (file)
@@ -51,7 +51,7 @@ public class XmlFileStorageAdapter implements StorageAdapter, Persister {
     }
 
     @Override
-    public Persister instantiate(PropertiesProvider propertiesProvider) {
+    public Persister instantiate(final PropertiesProvider propertiesProvider) {
         if(instance != null) {
             return instance;
         }
@@ -71,7 +71,7 @@ public class XmlFileStorageAdapter implements StorageAdapter, Persister {
                 if (!result) {
                     throw new RuntimeException("Unable to create storage file " + localStorage);
                 }
-            } catch (IOException e) {
+            } catch (final IOException e) {
                 throw new RuntimeException("Unable to create storage file " + localStorage, e);
             }
         }
@@ -98,16 +98,16 @@ public class XmlFileStorageAdapter implements StorageAdapter, Persister {
     }
 
     @VisibleForTesting
-    public void setFileStorage(File storage) {
+    public void setFileStorage(final File storage) {
         this.storage = storage;
     }
 
     @VisibleForTesting
-    public void setNumberOfBackups(Integer numberOfBackups) {
+    public void setNumberOfBackups(final Integer numberOfBackups) {
         numberOfStoredBackups = numberOfBackups;
     }
 
-    private static File extractStorageFileFromProperties(PropertiesProvider propertiesProvider) {
+    private static File extractStorageFileFromProperties(final PropertiesProvider propertiesProvider) {
         String fileStorageProperty = propertiesProvider.getProperty(FILE_STORAGE_PROP);
         Preconditions.checkNotNull(fileStorageProperty, "Unable to find " + propertiesProvider.getFullKeyForReporting(FILE_STORAGE_PROP));
         File result = new File(fileStorageProperty);
@@ -122,7 +122,7 @@ public class XmlFileStorageAdapter implements StorageAdapter, Persister {
     }
 
     @Override
-    public void persistConfig(ConfigSnapshotHolder holder) throws IOException {
+    public void persistConfig(final ConfigSnapshotHolder holder) throws IOException {
         Preconditions.checkNotNull(storage, "Storage file is null");
 
         Set<String> installedFeatureIds = Collections.emptySet();
index 63755f9e62c69d56c37dfa6442c91447bf42b8f7..e043e45feb94add6c36a0126f13a0b4ecf4b7690 100644 (file)
@@ -33,7 +33,7 @@ public final class Config {
 
     private List<ConfigSnapshot> snapshots;
 
-    Config(List<ConfigSnapshot> snapshots) {
+    Config(final List<ConfigSnapshot> snapshots) {
         this.snapshots = snapshots;
     }
 
@@ -47,11 +47,11 @@ public final class Config {
         return snapshots;
     }
 
-    public void setSnapshots(List<ConfigSnapshot> snapshots) {
+    public void setSnapshots(final List<ConfigSnapshot> snapshots) {
         this.snapshots = snapshots;
     }
 
-    public void toXml(File to) {
+    public void toXml(final File to) {
         try {
 
             // TODO Moxy has to be used instead of default jaxb impl due to a bug
@@ -63,12 +63,12 @@ public final class Config {
             marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
 
             marshaller.marshal(this, to);
-        } catch (JAXBException e) {
+        } catch (final JAXBException e) {
             throw new PersistException("Unable to persist configuration", e);
         }
     }
 
-    public static Config fromXml(File from) {
+    public static Config fromXml(final File from) {
         if(isEmpty(from)) {
             return new Config();
         }
@@ -86,14 +86,14 @@ public final class Config {
         }
     }
 
-    private static boolean isEmpty(File from) {
+    private static boolean isEmpty(final File from) {
         return from.length() == 0 || isBlank(from);
     }
 
-    private static boolean isBlank(File from) {
+    private static boolean isBlank(final File from) {
         try {
             return StringUtils.isBlank(Files.toString(from, StandardCharsets.UTF_8));
-        } catch (IOException e) {
+        } catch (final IOException e) {
             throw new IllegalStateException("Unexpected error reading file" + from, e);
         }
     }
@@ -103,14 +103,14 @@ public final class Config {
         return last == null ? Optional.<ConfigSnapshot>absent() : Optional.of(last);
     }
 
-    public void addConfigSnapshot(ConfigSnapshot snap, int numberOfStoredBackups) {
+    public void addConfigSnapshot(final ConfigSnapshot snap, final int numberOfStoredBackups) {
         if (shouldReplaceLast(numberOfStoredBackups) && !snapshots.isEmpty()) {
             snapshots.remove(0);
         }
         snapshots.add(snap);
     }
 
-    private boolean shouldReplaceLast(int numberOfStoredBackups) {
+    private boolean shouldReplaceLast(final int numberOfStoredBackups) {
         return numberOfStoredBackups == snapshots.size();
     }
 }
index 94cd58fc090e54443ad8619517020361149a4454..e84e75aa4d8fe0378de11c99973a00b1726b3670 100644 (file)
@@ -27,12 +27,12 @@ public class ConfigSnapshot {
     private SortedSet<String> capabilities = new TreeSet<>();
     private Set<String> features = new HashSet<>();
 
-    ConfigSnapshot(String configXml, SortedSet<String> capabilities) {
+    ConfigSnapshot(final String configXml, final SortedSet<String> capabilities) {
         this.configXml = configXml;
         this.capabilities = capabilities;
     }
 
-    ConfigSnapshot(String configXml, SortedSet<String> capabilities, Set<String> features) {
+    ConfigSnapshot(final String configXml, final SortedSet<String> capabilities, final Set<String> features) {
         this.configXml = configXml;
         this.capabilities = capabilities;
         this.features = features;
@@ -41,11 +41,11 @@ public class ConfigSnapshot {
     ConfigSnapshot() {
     }
 
-    public static ConfigSnapshot fromConfigSnapshot(ConfigSnapshotHolder cfg) {
+    public static ConfigSnapshot fromConfigSnapshot(final ConfigSnapshotHolder cfg) {
         return new ConfigSnapshot(cfg.getConfigSnapshot(), cfg.getCapabilities());
     }
 
-    public static ConfigSnapshot fromConfigSnapshot(ConfigSnapshotHolder cfg, Set<String> features) {
+    public static ConfigSnapshot fromConfigSnapshot(final ConfigSnapshotHolder cfg, final Set<String> features) {
         return new ConfigSnapshot(cfg.getConfigSnapshot(), cfg.getCapabilities(), features);
     }
 
@@ -54,7 +54,7 @@ public class ConfigSnapshot {
         return configXml;
     }
 
-    public void setConfigSnapshot(String configSnapshot) {
+    public void setConfigSnapshot(final String configSnapshot) {
         this.configXml = configSnapshot;
     }
 
@@ -65,7 +65,7 @@ public class ConfigSnapshot {
         return capabilities;
     }
 
-    public void setCapabilities(SortedSet<String> capabilities) {
+    public void setCapabilities(final SortedSet<String> capabilities) {
         this.capabilities = capabilities;
     }
 
index a0ccdb8e2e883294a57c75d3daf47c1c12ef1a2e..0c7d22c1dd543e9c887178a3e02a81062497df1e 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.controller.config.persist.storage.file.xml.model;
 final class PersistException extends RuntimeException {
     private static final long serialVersionUID = 1L;
 
-    public PersistException(String s, Exception e) {
+    public PersistException(final String s, final Exception e) {
         super(s, e);
     }
 }
index 2970367c719d55b0d6a27b725806ec66464cb952..e99694751b8726c8e9470a86400b211bc9476c74 100644 (file)
@@ -24,13 +24,13 @@ class SnapshotHandler implements DomHandler<String, StreamResult> {
     private StringWriter xmlWriter = new StringWriter();
 
     @Override
-    public StreamResult createUnmarshaller(ValidationEventHandler errorHandler) {
+    public StreamResult createUnmarshaller(final ValidationEventHandler errorHandler) {
         xmlWriter.getBuffer().setLength(0);
         return new StreamResult(xmlWriter);
     }
 
     @Override
-    public String getElement(StreamResult rt) {
+    public String getElement(final StreamResult rt) {
         String xml = rt.getWriter().toString();
         int beginIndex = xml.indexOf(START_TAG) + START_TAG.length();
         int endIndex = xml.indexOf(END_TAG);
@@ -40,12 +40,12 @@ class SnapshotHandler implements DomHandler<String, StreamResult> {
     }
 
     @Override
-    public Source marshal(String n, ValidationEventHandler errorHandler) {
+    public Source marshal(final String n, final ValidationEventHandler errorHandler) {
         try {
             String xml = START_TAG + n.trim() + END_TAG;
             StringReader xmlReader = new StringReader(xml);
             return new StreamSource(xmlReader);
-        } catch(Exception e) {
+        } catch(final Exception e) {
             throw new RuntimeException(e);
         }
     }
index 3c5f0bdab6b0de6029e0e93084a254b44867eba1..0308a726ab253fe5e1b1497df37bc52767837ac8 100644 (file)
@@ -11,7 +11,7 @@ import javax.xml.bind.annotation.adapters.XmlAdapter;
 
 final class StringTrimAdapter extends XmlAdapter<String, String> {
     @Override
-    public String unmarshal(String v) throws Exception {
+    public String unmarshal(final String v) throws Exception {
         if (v == null) {
             return null;
         }
@@ -19,7 +19,7 @@ final class StringTrimAdapter extends XmlAdapter<String, String> {
     }
 
     @Override
-    public String marshal(String v) throws Exception {
+    public String marshal(final String v) throws Exception {
         if (v == null) {
             return null;
         }