Class CompoundFunctionResolver
java.lang.Object
com.blackrook.rookscript.resolvers.hostfunction.CompoundFunctionResolver
- All Implemented Interfaces:
ScriptFunctionResolver
A host function resolver that is a combination of multiple resolvers.
Functions are resolved in the order that they are added to this resolver.
- Author:
- Matthew Tropiano
-
Field Summary
Fields inherited from interface com.blackrook.rookscript.resolvers.ScriptFunctionResolver
EMPTY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddFunction
(ScriptFunctionType functionType) Adds a script function type.addResolver
(ScriptFunctionResolver resolver) Adds all of the functions in a single resolver.clear()
Removes all resolvers (and all namespaced ones).boolean
containsFunction
(String name) Attempts to find if this resolver has a function by its calling name.getFunction
(String name) Attempts to resolve a pertinent function by its calling name.Gets the full list of all script functions.
-
Constructor Details
-
CompoundFunctionResolver
public CompoundFunctionResolver()Creates a new MultiHostFunctionResolver.
-
-
Method Details
-
addFunction
Adds a script function type. If a function has the same name as another function, this function overwrites the current mapping.- Parameters:
functionType
- the function type to add.- Returns:
- itself.
-
addResolver
Adds all of the functions in a single resolver.- Parameters:
resolver
- the resolver to add.- Returns:
- itself.
- See Also:
-
clear
Removes all resolvers (and all namespaced ones).- Returns:
- itself.
-
containsFunction
Description copied from interface:ScriptFunctionResolver
Attempts to find if this resolver has a function by its calling name.Names must be resolved case-insensitively!
If this returns
true
for a function name,ScriptFunctionResolver.getFunction(String)
must NOT return null if called with that name!- Specified by:
containsFunction
in interfaceScriptFunctionResolver
- Parameters:
name
- the name to find.- Returns:
- a corresponding function or null for no such function.
-
getFunction
Description copied from interface:ScriptFunctionResolver
Attempts to resolve a pertinent function by its calling name.Names must be resolved case-insensitively!
If this returns a non-null for a function name,
ScriptFunctionResolver.containsFunction(String)
must NOT returnfalse
if called with that name!The same function must be returned if this is called again with the same name!
- Specified by:
getFunction
in interfaceScriptFunctionResolver
- Parameters:
name
- the name to resolve.- Returns:
- a corresponding function or null for no such function.
- See Also:
-
getFunctions
Description copied from interface:ScriptFunctionResolver
Gets the full list of all script functions. Depending on the implementation, this may be an expensive lookup.- Specified by:
getFunctions
in interfaceScriptFunctionResolver
- Returns:
- a list of all functions.
-