From d5fed5ce48c4f4d24ac0330bbb68fa2c8c1ee0bd Mon Sep 17 00:00:00 2001 From: spikespaz Date: Fri, 24 Mar 2017 05:28:22 -0700 Subject: [PATCH] Remove all unused or verbose code in config --- src/main/java/fr/eyzox/bsc/config/Config.java | 8 -------- .../java/fr/eyzox/bsc/config/ConfigOptionGroup.java | 8 -------- .../java/fr/eyzox/bsc/config/IConfigListener.java | 2 +- .../java/fr/eyzox/bsc/config/IConfigProvider.java | 12 +++++------- .../bsc/config/loader/AbstractFileConfigLoader.java | 6 +++--- .../fr/eyzox/bsc/config/loader/ErrorManager.java | 4 ++-- .../fr/eyzox/bsc/config/loader/IConfigLoader.java | 10 +++++++--- .../fr/eyzox/bsc/config/loader/IErrorManager.java | 8 ++++---- .../fr/eyzox/bsc/config/loader/JSONConfigLoader.java | 5 ++--- .../java/fr/eyzox/bsc/exception/ConfigException.java | 12 ++---------- .../java/fr/eyzox/bsc/exception/FormatException.java | 4 ++-- .../eyzox/bsc/exception/InvalidValueException.java | 4 ++-- .../bsc/exception/MultiInvalidValueException.java | 2 +- .../forgecreeperheal/config/ConfigProvider.java | 5 ----- 14 files changed, 31 insertions(+), 59 deletions(-) diff --git a/src/main/java/fr/eyzox/bsc/config/Config.java b/src/main/java/fr/eyzox/bsc/config/Config.java index 9b55255..614d026 100644 --- a/src/main/java/fr/eyzox/bsc/config/Config.java +++ b/src/main/java/fr/eyzox/bsc/config/Config.java @@ -15,14 +15,6 @@ public void addOptionGroup(final ConfigOptionGroup optionGroup) { this.groups.put(optionGroup.getName(), optionGroup); } - public void removeOptionGroup(final ConfigOptionGroup optionGroup) { - this.removeOptionGroup(optionGroup.getName()); - } - - public void removeOptionGroup(final String optionGroupeName) { - this.groups.remove(optionGroupeName); - } - public ConfigOptionGroup getOptionGroup(final String name) { return groups.get(name); } diff --git a/src/main/java/fr/eyzox/bsc/config/ConfigOptionGroup.java b/src/main/java/fr/eyzox/bsc/config/ConfigOptionGroup.java index 7ff5eb2..1a5f193 100644 --- a/src/main/java/fr/eyzox/bsc/config/ConfigOptionGroup.java +++ b/src/main/java/fr/eyzox/bsc/config/ConfigOptionGroup.java @@ -23,14 +23,6 @@ public void addOption(final IConfigOption option) { this.options.put(option.getName(), option); } - public void removeOption(final String optionName) { - this.options.remove(optionName); - } - - public void removeOption(final IConfigOption option) { - this.removeOption(option.getName()); - } - public IConfigOption getOption(final String name) { return options.get(name); } diff --git a/src/main/java/fr/eyzox/bsc/config/IConfigListener.java b/src/main/java/fr/eyzox/bsc/config/IConfigListener.java index c106865..a040b1a 100644 --- a/src/main/java/fr/eyzox/bsc/config/IConfigListener.java +++ b/src/main/java/fr/eyzox/bsc/config/IConfigListener.java @@ -1,5 +1,5 @@ package fr.eyzox.bsc.config; public interface IConfigListener { - public void onChange(final Config config); + void onChange(final Config config); } diff --git a/src/main/java/fr/eyzox/bsc/config/IConfigProvider.java b/src/main/java/fr/eyzox/bsc/config/IConfigProvider.java index 187b34c..6fef29e 100644 --- a/src/main/java/fr/eyzox/bsc/config/IConfigProvider.java +++ b/src/main/java/fr/eyzox/bsc/config/IConfigProvider.java @@ -1,15 +1,13 @@ package fr.eyzox.bsc.config; public interface IConfigProvider { - public Config getConfig(); + Config getConfig(); - public void addConfigListener(final IConfigListener listener); + void addConfigListener(final IConfigListener listener); - public void removeConfigListener(final IConfigListener listener); + void fireConfigChanged(); - public void fireConfigChanged(); + void loadConfig(); - public void loadConfig(); - - public void unloadConfig(); + void unloadConfig(); } diff --git a/src/main/java/fr/eyzox/bsc/config/loader/AbstractFileConfigLoader.java b/src/main/java/fr/eyzox/bsc/config/loader/AbstractFileConfigLoader.java index b28c91f..4963d93 100644 --- a/src/main/java/fr/eyzox/bsc/config/loader/AbstractFileConfigLoader.java +++ b/src/main/java/fr/eyzox/bsc/config/loader/AbstractFileConfigLoader.java @@ -12,12 +12,12 @@ public abstract class AbstractFileConfigLoader implements IConfigLoader { private final File file; private final IErrorManager errorManager = new FileErrorManager(); - public AbstractFileConfigLoader(final File file) { + AbstractFileConfigLoader(final File file) { this.file = file; } @Override - public void load(Config config) throws NoSuchFileException, FileNotFoundException, AccessDeniedException, IOException, InvalidValueException { + public void load(Config config) throws IOException, InvalidValueException { if (!file.exists()) { throw new NoSuchFileException(file.getAbsolutePath()); } @@ -33,7 +33,7 @@ public void load(Config config) throws NoSuchFileException, FileNotFoundExceptio } @Override - public void save(Config config) throws FileNotFoundException, AccessDeniedException, IOException { + public void save(Config config) throws IOException { if (file.exists()) { if (!file.isFile()) { throw new FileNotFoundException(file.getAbsolutePath() + " is not a file"); diff --git a/src/main/java/fr/eyzox/bsc/config/loader/ErrorManager.java b/src/main/java/fr/eyzox/bsc/config/loader/ErrorManager.java index 4936089..41ec2e0 100644 --- a/src/main/java/fr/eyzox/bsc/config/loader/ErrorManager.java +++ b/src/main/java/fr/eyzox/bsc/config/loader/ErrorManager.java @@ -10,9 +10,9 @@ public class ErrorManager implements IErrorManager { - private final List errors = new LinkedList(); + private final List errors = new LinkedList<>(); - public ErrorManager() { + ErrorManager() { } @Override diff --git a/src/main/java/fr/eyzox/bsc/config/loader/IConfigLoader.java b/src/main/java/fr/eyzox/bsc/config/loader/IConfigLoader.java index 9465e89..856de52 100644 --- a/src/main/java/fr/eyzox/bsc/config/loader/IConfigLoader.java +++ b/src/main/java/fr/eyzox/bsc/config/loader/IConfigLoader.java @@ -1,11 +1,15 @@ package fr.eyzox.bsc.config.loader; import fr.eyzox.bsc.config.Config; +import fr.eyzox.bsc.exception.InvalidValueException; + +import java.io.IOException; +import java.nio.file.AccessDeniedException; public interface IConfigLoader { - public void load(final Config config) throws Exception; + void load(Config config) throws AccessDeniedException, IOException, InvalidValueException; - public void save(final Config config) throws Exception; + void save(final Config config) throws Exception; - public IErrorManager getErrorManager(); + IErrorManager getErrorManager(); } diff --git a/src/main/java/fr/eyzox/bsc/config/loader/IErrorManager.java b/src/main/java/fr/eyzox/bsc/config/loader/IErrorManager.java index 1883f8f..92da11a 100644 --- a/src/main/java/fr/eyzox/bsc/config/loader/IErrorManager.java +++ b/src/main/java/fr/eyzox/bsc/config/loader/IErrorManager.java @@ -7,11 +7,11 @@ import java.util.Collection; public interface IErrorManager { - public void error(ConfigException exception); + void error(ConfigException exception); - public boolean hasErrors(); + boolean hasErrors(); - public void output(final PrintWriter out) throws IOException; + void output(final PrintWriter out) throws IOException; - public Collection getErrors(); + Collection getErrors(); } diff --git a/src/main/java/fr/eyzox/bsc/config/loader/JSONConfigLoader.java b/src/main/java/fr/eyzox/bsc/config/loader/JSONConfigLoader.java index adbaafb..a93b989 100644 --- a/src/main/java/fr/eyzox/bsc/config/loader/JSONConfigLoader.java +++ b/src/main/java/fr/eyzox/bsc/config/loader/JSONConfigLoader.java @@ -14,7 +14,6 @@ import java.io.*; import java.nio.file.AccessDeniedException; -import java.nio.file.NoSuchFileException; import java.util.LinkedList; import java.util.List; @@ -25,7 +24,7 @@ public JSONConfigLoader(File file) { } @Override - public void load(Config config) throws NoSuchFileException, FileNotFoundException, AccessDeniedException, IOException, InvalidValueException { + public void load(Config config) throws IOException, InvalidValueException { super.load(config); InputStream input = null; try { @@ -40,7 +39,7 @@ public void load(Config config) throws NoSuchFileException, FileNotFoundExceptio } @Override - public void save(Config config) throws FileNotFoundException, AccessDeniedException, IOException { + public void save(Config config) throws IOException { super.save(config); OutputStream output = null; try { diff --git a/src/main/java/fr/eyzox/bsc/exception/ConfigException.java b/src/main/java/fr/eyzox/bsc/exception/ConfigException.java index f6a6ad5..d322b4a 100644 --- a/src/main/java/fr/eyzox/bsc/exception/ConfigException.java +++ b/src/main/java/fr/eyzox/bsc/exception/ConfigException.java @@ -2,15 +2,7 @@ public class ConfigException extends RuntimeException { - public ConfigException() { - super(); - } - - public ConfigException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { - super(message, cause, enableSuppression, writableStackTrace); - } - - public ConfigException(String message, Throwable cause) { + ConfigException(String message, Throwable cause) { super(message, cause); } @@ -18,7 +10,7 @@ public ConfigException(String message) { super(message); } - public ConfigException(Throwable cause) { + ConfigException(Throwable cause) { super(cause); } diff --git a/src/main/java/fr/eyzox/bsc/exception/FormatException.java b/src/main/java/fr/eyzox/bsc/exception/FormatException.java index 43d6e0c..0b3de2d 100644 --- a/src/main/java/fr/eyzox/bsc/exception/FormatException.java +++ b/src/main/java/fr/eyzox/bsc/exception/FormatException.java @@ -6,8 +6,8 @@ public FormatException(final String type, final String expected) { this(type, expected, null); } - public FormatException(final String type, final String expected, final Throwable cause) { - super(new StringBuilder("Invalid data type : \"").append(type).append("\" expected : \"").append(expected).append("\"").toString(), cause); + private FormatException(final String type, final String expected, final Throwable cause) { + super("Invalid data type : \"" + type + "\" expected : \"" + expected + "\"", cause); } } diff --git a/src/main/java/fr/eyzox/bsc/exception/InvalidValueException.java b/src/main/java/fr/eyzox/bsc/exception/InvalidValueException.java index 6257316..8b41290 100644 --- a/src/main/java/fr/eyzox/bsc/exception/InvalidValueException.java +++ b/src/main/java/fr/eyzox/bsc/exception/InvalidValueException.java @@ -22,7 +22,7 @@ public InvalidValueException(final String value, final String expected, final Th this.value = value; } - public IConfigOption getConfigOption() { + private IConfigOption getConfigOption() { return configOption; } @@ -30,7 +30,7 @@ public void setConfigOption(IConfigOption configOption) { this.configOption = configOption; } - public String getExpected() { + private String getExpected() { return expected; } diff --git a/src/main/java/fr/eyzox/bsc/exception/MultiInvalidValueException.java b/src/main/java/fr/eyzox/bsc/exception/MultiInvalidValueException.java index fcb5164..8558dd5 100644 --- a/src/main/java/fr/eyzox/bsc/exception/MultiInvalidValueException.java +++ b/src/main/java/fr/eyzox/bsc/exception/MultiInvalidValueException.java @@ -5,7 +5,7 @@ public class MultiInvalidValueException extends InvalidValueException { - private final Collection exceptions = new LinkedList(); + private final Collection exceptions = new LinkedList<>(); public MultiInvalidValueException(String value) { super(value); diff --git a/src/main/java/fr/eyzox/forgecreeperheal/config/ConfigProvider.java b/src/main/java/fr/eyzox/forgecreeperheal/config/ConfigProvider.java index ed6aae5..4a65253 100644 --- a/src/main/java/fr/eyzox/forgecreeperheal/config/ConfigProvider.java +++ b/src/main/java/fr/eyzox/forgecreeperheal/config/ConfigProvider.java @@ -76,11 +76,6 @@ public synchronized void addConfigListener(IConfigListener listener) { this.listeners.add(listener); } - @Override - public synchronized void removeConfigListener(IConfigListener listener) { - this.listeners.remove(listener); - } - @Override public synchronized void loadConfig() { config = loadDefaultConfig();