From cda09518c334e62d0d9586f835fef229c40cd4e5 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Wed, 2 Aug 2017 18:33:58 -0700 Subject: [PATCH] Add the disabled plugins configuration option. --- .../nwapw/abacus/config/Configuration.java | 47 ++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/nwapw/abacus/config/Configuration.java b/src/main/java/org/nwapw/abacus/config/Configuration.java index 6253632..9a511cf 100644 --- a/src/main/java/org/nwapw/abacus/config/Configuration.java +++ b/src/main/java/org/nwapw/abacus/config/Configuration.java @@ -5,6 +5,10 @@ import com.moandjiezana.toml.TomlWriter; import java.io.File; import java.io.IOException; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; /** * The configuration object that stores @@ -25,13 +29,19 @@ public class Configuration { * The implementation of the number that should be used. */ private String numberImplementation = "naive"; + /** + * The list of disabled plugins in this Configuration. + */ + private Set disabledPlugins = new HashSet<>(); /** * Creates a new configuration with the given values. * @param numberImplementation the number implementation, like "naive" or "precise" + * @param disabledPlugins the list of disabled plugins. */ - public Configuration(String numberImplementation){ + public Configuration(String numberImplementation, String[] disabledPlugins){ this.numberImplementation = numberImplementation; + this.disabledPlugins.addAll(Arrays.asList(disabledPlugins)); } /** @@ -49,6 +59,7 @@ public class Configuration { */ public void copyFrom(Configuration otherConfiguration){ this.numberImplementation = otherConfiguration.numberImplementation; + this.disabledPlugins.addAll(otherConfiguration.disabledPlugins); } /** @@ -80,4 +91,38 @@ public class Configuration { public void setNumberImplementation(String numberImplementation) { this.numberImplementation = numberImplementation; } + + /** + * Gets the list of disabled plugins. + * @return the list of disabled plugins. + */ + public Set getDisabledPlugins() { + return disabledPlugins; + } + + /** + * Adds the given plugin to the disabled plugins list. + * @param pluginClass the plugin to disable. + */ + public void disablePlugin(String pluginClass){ + disabledPlugins.add(pluginClass); + } + + /** + * Removes the given plugin from the disabled plugins list. + * @param pluginClass the plugin to enable. + */ + public void enablePlugin(String pluginClass){ + disabledPlugins.remove(pluginClass); + } + + /** + * Sets the disabled plugins to be as specified. + * @param newDisabled the new list of disabled plugins. + */ + public void setDisabledPlugins(Collection newDisabled){ + disabledPlugins.clear(); + disabledPlugins.addAll(newDisabled); + } + }