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

public class SimpleFunction extends BaseRealizableFunction

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.

  • 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

      public SimpleFunction withArguments(nz.org.riskscape.engine.function.ArgumentList args)
    • withArguments

      public SimpleFunction withArguments(nz.org.riskscape.engine.function.FunctionArgument... args)
    • withReturnType

      public SimpleFunction withReturnType(nz.org.riskscape.engine.types.Type returnType)
    • calling

      public SimpleFunction calling(nz.org.riskscape.engine.function.UntypedFunction newImplementation)

      Defines the main body of the function call

    • callingUnary

      public SimpleFunction callingUnary(Function<Object,Object> newImplementation)

      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: BaseRealizableFunction

      This 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:
      build in class BaseRealizableFunction
      Throws:
      nz.org.riskscape.problem.ProblemException