Package nz.org.riskscape.engine.function
Class SimpleFunction
java.lang.Object
nz.org.riskscape.engine.function.BaseRealizableFunction
nz.org.riskscape.engine.function.SimpleFunction
- All Implemented Interfaces:
nz.org.riskscape.engine.rl.RealizableFunction
Helper to make it easy to define RiskScape functions with a simple function body. These functions reuse the BaseRealizableFunction validation and FunctionArgument code, although they don't need to be realizable per se.
-
Nested Class Summary
Nested classes/interfaces inherited from interface nz.org.riskscape.engine.rl.RealizableFunction
nz.org.riskscape.engine.rl.RealizableFunction.MetadataIdentifiedRealizableFunction -
Field Summary
Fields inherited from class nz.org.riskscape.engine.function.BaseRealizableFunction
arguments, beta, returnType -
Constructor Summary
ConstructorsConstructorDescriptionSimpleFunction(nz.org.riskscape.engine.function.ArgumentList arguments, nz.org.riskscape.engine.types.Type returnType, nz.org.riskscape.engine.function.UntypedFunction implementation) -
Method Summary
Modifier and TypeMethodDescriptionprotected nz.org.riskscape.engine.function.RiskscapeFunctionbuild(nz.org.riskscape.engine.rl.RealizationContext context, nz.org.riskscape.rl.ast.FunctionCall functionCall, List<nz.org.riskscape.engine.types.Type> givenTypes) This method is internal to the sub-class.calling(nz.org.riskscape.engine.function.UntypedFunction newImplementation) Defines the main body of the function callcallingUnary(Function<Object, Object> newImplementation) Defines the main body of the function call, for a function that accepts a single argswithArguments(nz.org.riskscape.engine.function.ArgumentList args) withArguments(nz.org.riskscape.engine.function.FunctionArgument... args) withReturnType(nz.org.riskscape.engine.types.Type returnType) Methods inherited from class nz.org.riskscape.engine.function.BaseRealizableFunction
asFunction, beta, buildFunction, builtin, getArguments, getReturnType, identified, realizeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface nz.org.riskscape.engine.rl.RealizableFunction
isDoTypeAdaptation
-
Constructor Details
-
SimpleFunction
public SimpleFunction() -
SimpleFunction
public SimpleFunction(nz.org.riskscape.engine.function.ArgumentList arguments, nz.org.riskscape.engine.types.Type returnType, nz.org.riskscape.engine.function.UntypedFunction implementation)
-
-
Method Details
-
withArguments
-
withArguments
-
withReturnType
-
calling
Defines the main body of the function call
-
callingUnary
Defines the main body of the function call, for a function that accepts a single args
-
build
protected nz.org.riskscape.engine.function.RiskscapeFunction build(nz.org.riskscape.engine.rl.RealizationContext context, nz.org.riskscape.rl.ast.FunctionCall functionCall, List<nz.org.riskscape.engine.types.Type> givenTypes) throws nz.org.riskscape.problem.ProblemException Description copied from class:BaseRealizableFunctionThis method is internal to the sub-class. Simple realizable functions can just implement this, to jump straight to the meat of building the realized function. You should throw a ProblemException for any errors encountered.
- Overrides:
buildin classBaseRealizableFunction- Throws:
nz.org.riskscape.problem.ProblemException
-