Class DefaultFunctionResolver

java.lang.Object
nz.org.riskscape.engine.DefaultFunctionResolver
All Implemented Interfaces:
nz.org.riskscape.engine.function.FunctionResolver

public class DefaultFunctionResolver extends Object implements nz.org.riskscape.engine.function.FunctionResolver
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> T
    evaluateConstant(nz.org.riskscape.engine.rl.RealizationContext context, nz.org.riskscape.rl.ast.FunctionCall functionCall, int argIndex, Class<T> requiredJavaType, nz.org.riskscape.engine.types.Type requiredType)
    Helper method for a RealizableFunction to extract a constant from the arguments with various error handling along the way.
    nz.org.riskscape.problem.ResultOrProblems<nz.org.riskscape.engine.function.RiskscapeFunction>
    resolve(nz.org.riskscape.engine.rl.RealizationContext context, nz.org.riskscape.rl.ast.FunctionCall functionCall, nz.org.riskscape.engine.types.Type inputType, List<nz.org.riskscape.engine.types.Type> argumentTypes, nz.org.riskscape.engine.function.IdentifiedFunction function)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DefaultFunctionResolver

      public DefaultFunctionResolver()
  • Method Details

    • evaluateConstant

      public static <T> T evaluateConstant(nz.org.riskscape.engine.rl.RealizationContext context, nz.org.riskscape.rl.ast.FunctionCall functionCall, int argIndex, Class<T> requiredJavaType, nz.org.riskscape.engine.types.Type requiredType) throws nz.org.riskscape.problem.ProblemException

      Helper method for a RealizableFunction to extract a constant from the arguments with various error handling along the way. This method will fail if the expression is not a constant expression (e.g. it depends on values extracted from scope).

      Type Parameters:
      T -
      Parameters:
      context - context in which realization is happening - typically the argument that was passed to RealizableFunction.realize(RealizationContext, FunctionCall, List)
      functionCall - the functionCall expression that contains an argument to be realized constantly
      argIndex - the index of the argument (0 based) that should be a constant
      requiredJavaType - the desired java type of the constant - must map to a built-in riskscape type via Types.fromJavaType(Class)
      requiredType - the Riskscape version of the requiredJavaType argument. Is only used for a problem and no riskscape type checking is actually done against this type.
      Returns:
      the constant value from the function call expression
      Throws:
      nz.org.riskscape.problem.ProblemException - if the expression was bad, not a constant, or of the wrong type. Contained problem should be suitable for display to the user without wrapping with more function-call specific context
    • resolve

      public nz.org.riskscape.problem.ResultOrProblems<nz.org.riskscape.engine.function.RiskscapeFunction> resolve(nz.org.riskscape.engine.rl.RealizationContext context, nz.org.riskscape.rl.ast.FunctionCall functionCall, nz.org.riskscape.engine.types.Type inputType, List<nz.org.riskscape.engine.types.Type> argumentTypes, nz.org.riskscape.engine.function.IdentifiedFunction function)
      Specified by:
      resolve in interface nz.org.riskscape.engine.function.FunctionResolver