Remove unused code.
[Sone.git] / src / main / java / net / pterodactylus / sone / freenet / PluginStoreConfigurationBackend.java
index eebfe3e..a0690a4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * FreenetSone - PluginStoreConfigurationBackend.java - Copyright © 2010 David Roden
+ * Sone - PluginStoreConfigurationBackend.java - Copyright © 2010–2013 David Roden
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -17,7 +17,6 @@
 
 package net.pterodactylus.sone.freenet;
 
-import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import net.pterodactylus.util.config.AttributeNotFoundException;
@@ -37,6 +36,7 @@ import freenet.pluginmanager.PluginStore;
 public class PluginStoreConfigurationBackend implements ExtendedConfigurationBackend {
 
        /** The logger. */
+       @SuppressWarnings("unused")
        private static final Logger logger = Logging.getLogger(PluginStoreConfigurationBackend.class);
 
        /** The plugin respirator. */
@@ -56,11 +56,11 @@ public class PluginStoreConfigurationBackend implements ExtendedConfigurationBac
        public PluginStoreConfigurationBackend(PluginRespirator pluginRespirator) throws DatabaseDisabledException {
                this.pluginRespirator = pluginRespirator;
                this.pluginStore = pluginRespirator.getStore();
+               if (this.pluginStore == null) {
+                       throw new DatabaseDisabledException();
+               }
        }
 
-       /**
-        * {@inheritDoc}
-        */
        @Override
        public String getValue(String attribute) throws ConfigurationException {
                if (!pluginStore.strings.containsKey(attribute)) {
@@ -69,18 +69,12 @@ public class PluginStoreConfigurationBackend implements ExtendedConfigurationBac
                return pluginStore.strings.get(attribute);
        }
 
-       /**
-        * {@inheritDoc}
-        */
        @Override
        public void putValue(String attribute, String value) throws ConfigurationException {
                pluginStore.strings.put(attribute, value);
                save();
        }
 
-       /**
-        * {@inheritDoc}
-        */
        @Override
        public Boolean getBooleanValue(String attribute) throws ConfigurationException {
                if (!pluginStore.booleans.containsKey(attribute)) {
@@ -89,18 +83,12 @@ public class PluginStoreConfigurationBackend implements ExtendedConfigurationBac
                return pluginStore.booleans.get(attribute);
        }
 
-       /**
-        * {@inheritDoc}
-        */
        @Override
        public void setBooleanValue(String attribute, Boolean value) throws ConfigurationException {
                pluginStore.booleans.put(attribute, value);
                save();
        }
 
-       /**
-        * {@inheritDoc}
-        */
        @Override
        public Double getDoubleValue(String attribute) throws ConfigurationException {
                if (!pluginStore.strings.containsKey(attribute)) {
@@ -117,18 +105,12 @@ public class PluginStoreConfigurationBackend implements ExtendedConfigurationBac
                }
        }
 
-       /**
-        * {@inheritDoc}
-        */
        @Override
        public void setDoubleValue(String attribute, Double value) throws ConfigurationException {
                pluginStore.strings.put(attribute, String.valueOf(value));
                save();
        }
 
-       /**
-        * {@inheritDoc}
-        */
        @Override
        public Integer getIntegerValue(String attribute) throws ConfigurationException {
                if (!pluginStore.integers.containsKey(attribute)) {
@@ -137,18 +119,12 @@ public class PluginStoreConfigurationBackend implements ExtendedConfigurationBac
                return pluginStore.integers.get(attribute);
        }
 
-       /**
-        * {@inheritDoc}
-        */
        @Override
        public void setIntegerValue(String attribute, Integer value) throws ConfigurationException {
                pluginStore.integers.put(attribute, value);
                save();
        }
 
-       /**
-        * {@inheritDoc}
-        */
        @Override
        public Long getLongValue(String attribute) throws ConfigurationException {
                if (!pluginStore.longs.containsKey(attribute)) {
@@ -157,27 +133,18 @@ public class PluginStoreConfigurationBackend implements ExtendedConfigurationBac
                return pluginStore.longs.get(attribute);
        }
 
-       /**
-        * {@inheritDoc}
-        */
        @Override
        public void setLongValue(String attribute, Long value) throws ConfigurationException {
                pluginStore.longs.put(attribute, value);
                save();
        }
 
-       //
-       // PRIVATE METHODS
-       //
-
-       /**
-        * Saves the configuration to the plugin store.
-        */
-       private void save() {
+       @Override
+       public void save() throws ConfigurationException {
                try {
                        pluginRespirator.putStore(pluginStore);
                } catch (DatabaseDisabledException dde1) {
-                       logger.log(Level.WARNING, "Could not store plugin store, database is disabled.", dde1);
+                       throw new ConfigurationException("Could not store plugin store, database is disabled.", dde1);
                }
        }