From 91f238f7e2f569c3b77a60c0678602566636f127 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Wed, 2 Aug 2017 21:57:53 -0700 Subject: [PATCH] Add defaults that actually work. --- .../org/nwapw/abacus/config/Configuration.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/nwapw/abacus/config/Configuration.java b/src/main/java/org/nwapw/abacus/config/Configuration.java index 69e1272..951edee 100644 --- a/src/main/java/org/nwapw/abacus/config/Configuration.java +++ b/src/main/java/org/nwapw/abacus/config/Configuration.java @@ -15,19 +15,25 @@ import java.util.Set; */ public class Configuration { + /** + * The defaults TOML string. + */ + private static final String DEFAULT_CONFIG = + "numberImplementation = \"naive\"\n" + + "disabledPlugins = []"; + /** + * The defaults TOML object, parsed from the string. + */ + private static final Toml DEFAULT_TOML = new Toml().read(DEFAULT_CONFIG); /** * The TOML writer used to write this configuration to a file. */ private static final TomlWriter TOML_WRITER = new TomlWriter(); - /** - * The TOML reader used to load this config from a file. - */ - private static final Toml TOML_READER = new Toml(); /** * The implementation of the number that should be used. */ - private String numberImplementation = "naive"; + private String numberImplementation = ""; /** * The list of disabled plugins in this Configuration. */ @@ -49,7 +55,7 @@ public class Configuration { */ public Configuration(File fromFile){ if(!fromFile.exists()) return; - copyFrom(TOML_READER.read(fromFile).to(Configuration.class)); + copyFrom(new Toml(DEFAULT_TOML).read(fromFile).to(Configuration.class)); } /**