Package nz.org.riskscape.engine.function
Class UserDefinedFunction
java.lang.Object
nz.org.riskscape.engine.function.UserDefinedFunction
- All Implemented Interfaces:
nz.org.riskscape.engine.rl.RealizableFunction
public abstract class UserDefinedFunction
extends Object
implements nz.org.riskscape.engine.rl.RealizableFunction
Represents a function defined by the user in a script file (e.g. Jython, CPython, etc). User-defined functions are realizable, so we can provide the user with an in-depth error message if the types don't line up. Users are much more likely to hit type errors defining their own functions, so we can be more specific about pointing them in the right direction.
-
Nested Class Summary
Nested classes/interfaces inherited from interface nz.org.riskscape.engine.rl.RealizableFunction
nz.org.riskscape.engine.rl.RealizableFunction.MetadataIdentifiedRealizableFunction
-
Constructor Summary
ConstructorDescriptionUserDefinedFunction
(nz.org.riskscape.engine.function.FunctionMetadata details, nz.org.riskscape.engine.resource.Resource script) -
Method Summary
Modifier and TypeMethodDescriptionboolean
areArgumentsCompatible
(nz.org.riskscape.engine.rl.RealizationContext context, List<nz.org.riskscape.engine.types.Type> givenArgs) List<nz.org.riskscape.problem.Problem>
getArgumentProblems
(nz.org.riskscape.engine.rl.RealizationContext context, List<nz.org.riskscape.engine.types.Type> givenArgs) List<nz.org.riskscape.engine.types.Type>
nz.org.riskscape.engine.function.FunctionMetadata
nz.org.riskscape.engine.resource.Resource
nz.org.riskscape.engine.function.IdentifiedFunction
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface nz.org.riskscape.engine.rl.RealizableFunction
realize
-
Constructor Details
-
UserDefinedFunction
public UserDefinedFunction(nz.org.riskscape.engine.function.FunctionMetadata details, nz.org.riskscape.engine.resource.Resource script)
-
-
Method Details
-
getDeclaredArgumentTypes
-
areArgumentsCompatible
public boolean areArgumentsCompatible(nz.org.riskscape.engine.rl.RealizationContext context, List<nz.org.riskscape.engine.types.Type> givenArgs) - Returns:
- true if the given arguments are compatible with this function, false if not
-
getArgumentProblems
public List<nz.org.riskscape.problem.Problem> getArgumentProblems(nz.org.riskscape.engine.rl.RealizationContext context, List<nz.org.riskscape.engine.types.Type> givenArgs) - Returns:
- A list of problems associated with the given arguments, or an empty list if there are no problems
-
identified
public nz.org.riskscape.engine.function.IdentifiedFunction identified() -
getMetadata
public nz.org.riskscape.engine.function.FunctionMetadata getMetadata() -
getScript
public nz.org.riskscape.engine.resource.Resource getScript()
-