Skip to content
This repository has been archived by the owner on Apr 4, 2022. It is now read-only.

Commit

Permalink
Remove all unused or verbose code in config
Browse files Browse the repository at this point in the history
  • Loading branch information
spikespaz committed Mar 24, 2017
1 parent a41a027 commit d5fed5c
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 59 deletions.
8 changes: 0 additions & 8 deletions src/main/java/fr/eyzox/bsc/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
8 changes: 0 additions & 8 deletions src/main/java/fr/eyzox/bsc/config/ConfigOptionGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/fr/eyzox/bsc/config/IConfigListener.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package fr.eyzox.bsc.config;

public interface IConfigListener {
public void onChange(final Config config);
void onChange(final Config config);
}
12 changes: 5 additions & 7 deletions src/main/java/fr/eyzox/bsc/config/IConfigProvider.java
Original file line number Diff line number Diff line change
@@ -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();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand All @@ -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");
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/fr/eyzox/bsc/config/loader/ErrorManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

public class ErrorManager implements IErrorManager {

private final List<ConfigException> errors = new LinkedList<ConfigException>();
private final List<ConfigException> errors = new LinkedList<>();

public ErrorManager() {
ErrorManager() {
}

@Override
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/fr/eyzox/bsc/config/loader/IConfigLoader.java
Original file line number Diff line number Diff line change
@@ -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();
}
8 changes: 4 additions & 4 deletions src/main/java/fr/eyzox/bsc/config/loader/IErrorManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<ConfigException> getErrors();
Collection<ConfigException> getErrors();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
12 changes: 2 additions & 10 deletions src/main/java/fr/eyzox/bsc/exception/ConfigException.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,15 @@

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);
}

public ConfigException(String message) {
super(message);
}

public ConfigException(Throwable cause) {
ConfigException(Throwable cause) {
super(cause);
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/fr/eyzox/bsc/exception/FormatException.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ public InvalidValueException(final String value, final String expected, final Th
this.value = value;
}

public IConfigOption getConfigOption() {
private IConfigOption getConfigOption() {
return configOption;
}

public void setConfigOption(IConfigOption configOption) {
this.configOption = configOption;
}

public String getExpected() {
private String getExpected() {
return expected;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class MultiInvalidValueException extends InvalidValueException {

private final Collection<InvalidValueException> exceptions = new LinkedList<InvalidValueException>();
private final Collection<InvalidValueException> exceptions = new LinkedList<>();

public MultiInvalidValueException(String value) {
super(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit d5fed5c

Please sign in to comment.