mirror of
https://github.com/DanilaFe/abacus
synced 2024-11-16 23:53:09 -08:00
Add registering TreeValueOperators.
This commit is contained in:
parent
5b1a48c02e
commit
73075c57b9
|
@ -89,6 +89,18 @@ public abstract class Plugin {
|
|||
manager.registerOperator(name, operator);
|
||||
}
|
||||
|
||||
/**
|
||||
* To be used in load(). Registers an operator
|
||||
* with the plugin internally, which makes it accessible
|
||||
* to the plugin manager.
|
||||
*
|
||||
* @param name the name of the tree value operator.
|
||||
* @param operator the tree value operator to register.
|
||||
*/
|
||||
protected final void registerTreeValueOperator(String name, TreeValueOperator operator){
|
||||
manager.registerTreeValueOperator(name, operator);
|
||||
}
|
||||
|
||||
/**
|
||||
* To be used in load(). Registers a new number implementation with the plugin.
|
||||
* This makes it accessible to the plugin manager.
|
||||
|
@ -146,6 +158,18 @@ public abstract class Plugin {
|
|||
return manager.operatorFor(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches the PluginManager for the given tree value operator name.
|
||||
* This can be used by the plugins internally in order to call
|
||||
* operations they do not provide.
|
||||
*
|
||||
* @param name the name for which to search.
|
||||
* @return the resulting tree value operator, or null if none was found for that name.
|
||||
*/
|
||||
protected final TreeValueOperator treeValueOperatorFor(String name) {
|
||||
return manager.treeValueOperatorFor(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches the PluginManager for the given number implementation
|
||||
* name. This can be used by the plugins internally in order to find
|
||||
|
|
|
@ -36,6 +36,10 @@ public class PluginManager {
|
|||
* The map of operators registered by the plugins
|
||||
*/
|
||||
private Map<String, NumberOperator> registeredOperators;
|
||||
/**
|
||||
* The map of tree value operators registered by the plugins.
|
||||
*/
|
||||
private Map<String, TreeValueOperator> registeredTreeValueOperators;
|
||||
/**
|
||||
* The map of number implementations registered by the plugins.
|
||||
*/
|
||||
|
@ -75,6 +79,7 @@ public class PluginManager {
|
|||
registeredFunctions = new HashMap<>();
|
||||
registeredTreeValueFunctions = new HashMap<>();
|
||||
registeredOperators = new HashMap<>();
|
||||
registeredTreeValueOperators = new HashMap<>();
|
||||
registeredNumberImplementations = new HashMap<>();
|
||||
registeredDocumentation = new HashSet<>();
|
||||
cachedInterfaceImplementations = new HashMap<>();
|
||||
|
@ -112,6 +117,16 @@ public class PluginManager {
|
|||
registeredOperators.put(name, operator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a tree value operator under the given name.
|
||||
*
|
||||
* @param name the name of the tree value operator.
|
||||
* @param operator the tree value operator to register.
|
||||
*/
|
||||
public void registerTreeValueOperator(String name, TreeValueOperator operator){
|
||||
registeredTreeValueOperators.put(name, operator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a number implementation under the given name.
|
||||
*
|
||||
|
@ -162,6 +177,16 @@ public class PluginManager {
|
|||
return registeredOperators.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the tree value operator registered under the given name.
|
||||
*
|
||||
* @param name the name of the tree value operator.
|
||||
* @return the operator, or null if it was not found.
|
||||
*/
|
||||
public TreeValueOperator treeValueOperatorFor(String name) {
|
||||
return registeredTreeValueOperators.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number implementation registered under the given name.
|
||||
*
|
||||
|
@ -299,7 +324,9 @@ public class PluginManager {
|
|||
plugin.disable();
|
||||
}
|
||||
registeredFunctions.clear();
|
||||
registeredTreeValueFunctions.clear();
|
||||
registeredOperators.clear();
|
||||
registeredTreeValueOperators.clear();
|
||||
registeredNumberImplementations.clear();
|
||||
registeredDocumentation.clear();
|
||||
cachedInterfaceImplementations.clear();
|
||||
|
@ -342,6 +369,15 @@ public class PluginManager {
|
|||
return registeredOperators.keySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all the tree value operators loaded by the PluginManager.
|
||||
*
|
||||
* @return the set of all tree value operators that were loaded.
|
||||
*/
|
||||
public Set<String> getAllTreeValueOperators(){
|
||||
return registeredTreeValueOperators.keySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all the number implementations loaded by the Plugin Manager.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue
Block a user