1
0
mirror of https://github.com/DanilaFe/abacus synced 2024-12-22 23:40:08 -08:00

Get rid of unnecessary supplier.

This commit is contained in:
Danila Fedorin 2017-08-05 17:06:22 -07:00
parent 9efe9be5b4
commit 467d5d4145
3 changed files with 12 additions and 5 deletions

View File

@ -12,8 +12,6 @@ import org.nwapw.abacus.plugin.StandardPlugin;
import org.nwapw.abacus.tree.NumberReducer; import org.nwapw.abacus.tree.NumberReducer;
import org.nwapw.abacus.tree.TreeNode; import org.nwapw.abacus.tree.TreeNode;
import java.util.function.Supplier;
/** /**
* The main calculator class. This is responsible * The main calculator class. This is responsible
* for piecing together all of the components, allowing * for piecing together all of the components, allowing
@ -49,10 +47,10 @@ public class Abacus {
/** /**
* Creates a new instance of the Abacus calculator. * Creates a new instance of the Abacus calculator.
*/ */
public Abacus(Supplier<Configuration> configurationSupplier) { public Abacus(Configuration configuration) {
pluginManager = new PluginManager(this); pluginManager = new PluginManager(this);
numberReducer = new NumberReducer(this); numberReducer = new NumberReducer(this);
configuration = configurationSupplier.get(); this.configuration = new Configuration(configuration);
LexerTokenizer lexerTokenizer = new LexerTokenizer(); LexerTokenizer lexerTokenizer = new LexerTokenizer();
ShuntingYardParser shuntingYardParser = new ShuntingYardParser(this); ShuntingYardParser shuntingYardParser = new ShuntingYardParser(this);
treeBuilder = new TreeBuilder<>(lexerTokenizer, shuntingYardParser); treeBuilder = new TreeBuilder<>(lexerTokenizer, shuntingYardParser);

View File

@ -39,6 +39,15 @@ public class Configuration {
*/ */
private Set<String> disabledPlugins = new HashSet<>(); private Set<String> disabledPlugins = new HashSet<>();
/**
* Creates a new configuration form the given configuration.
*
* @param copyFrom the configuration to copy.
*/
public Configuration(Configuration copyFrom){
copyFrom(copyFrom);
}
/** /**
* Creates a new configuration with the given values. * Creates a new configuration with the given values.
* *

View File

@ -180,7 +180,7 @@ public class AbacusController implements PluginListener {
if (oldValue.equals(settingsTab)) alertIfApplyNeeded(true); if (oldValue.equals(settingsTab)) alertIfApplyNeeded(true);
}); });
abacus = new Abacus(() -> new Configuration(new java.io.File("config.toml"))); abacus = new Abacus(new Configuration(CONFIG_FILE));
PluginManager abacusPluginManager = abacus.getPluginManager(); PluginManager abacusPluginManager = abacus.getPluginManager();
abacusPluginManager.addListener(this); abacusPluginManager.addListener(this);
abacusPluginManager.addInstantiated(new StandardPlugin(abacus.getPluginManager())); abacusPluginManager.addInstantiated(new StandardPlugin(abacus.getPluginManager()));