1
0
mirror of https://github.com/DanilaFe/abacus synced 2026-01-27 00:55:19 +00:00

Format code.

This commit is contained in:
2017-08-04 13:20:57 -07:00
parent b036b6c242
commit 39b36f84e0
14 changed files with 317 additions and 286 deletions

View File

@@ -20,7 +20,7 @@ public class Configuration {
*/
private static final String DEFAULT_CONFIG =
"numberImplementation = \"naive\"\n" +
"disabledPlugins = []";
"disabledPlugins = []";
/**
* The defaults TOML object, parsed from the string.
*/
@@ -41,28 +41,31 @@ public class Configuration {
/**
* Creates a new configuration with the given values.
*
* @param numberImplementation the number implementation, like "naive" or "precise"
* @param disabledPlugins the list of disabled plugins.
* @param disabledPlugins the list of disabled plugins.
*/
public Configuration(String numberImplementation, String[] disabledPlugins){
public Configuration(String numberImplementation, String[] disabledPlugins) {
this.numberImplementation = numberImplementation;
this.disabledPlugins.addAll(Arrays.asList(disabledPlugins));
}
/**
* Loads a configuration from a given file, keeping non-specified fields default.
*
* @param fromFile the file to load from.
*/
public Configuration(File fromFile){
if(!fromFile.exists()) return;
public Configuration(File fromFile) {
if (!fromFile.exists()) return;
copyFrom(new Toml(DEFAULT_TOML).read(fromFile).to(Configuration.class));
}
/**
* Copies the values from the given configuration into this one.
*
* @param otherConfiguration the configuration to copy from.
*/
public void copyFrom(Configuration otherConfiguration){
public void copyFrom(Configuration otherConfiguration) {
this.numberImplementation = otherConfiguration.numberImplementation;
this.disabledPlugins.addAll(otherConfiguration.disabledPlugins);
}
@@ -70,10 +73,11 @@ public class Configuration {
/**
* Saves this configuration to the given file, creating
* any directories that do not exist.
*
* @param file the file to save to.
*/
public void saveTo(File file){
if(file.getParentFile() != null) file.getParentFile().mkdirs();
public void saveTo(File file) {
if (file.getParentFile() != null) file.getParentFile().mkdirs();
try {
TOML_WRITER.write(this, file);
} catch (IOException e) {
@@ -83,6 +87,7 @@ public class Configuration {
/**
* Gets the number implementation from this configuration.
*
* @return the number implementation.
*/
public String getNumberImplementation() {
@@ -91,6 +96,7 @@ public class Configuration {
/**
* Sets the number implementation for the configuration
*
* @param numberImplementation the number implementation.
*/
public void setNumberImplementation(String numberImplementation) {
@@ -99,6 +105,7 @@ public class Configuration {
/**
* Gets the list of disabled plugins.
*
* @return the list of disabled plugins.
*/
public Set<String> getDisabledPlugins() {