Class DefaultExpressionRealizer

java.lang.Object
nz.org.riskscape.engine.rl.DefaultExpressionRealizer
All Implemented Interfaces:
nz.org.riskscape.engine.rl.ExpressionRealizer

public class DefaultExpressionRealizer extends Object implements nz.org.riskscape.engine.rl.ExpressionRealizer

Realizes riskscape language expressions in to reified/realized objects that can be evaluated.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface nz.org.riskscape.engine.rl.ExpressionRealizer

    nz.org.riskscape.engine.rl.ExpressionRealizer.ProblemCodes
  • Field Summary

    Fields inherited from interface nz.org.riskscape.engine.rl.ExpressionRealizer

    NO_SUCH_MEMBER
  • Constructor Summary

    Constructors
    Constructor
    Description
    DefaultExpressionRealizer(@NonNull nz.org.riskscape.engine.rl.RealizationContext context)
     
    DefaultExpressionRealizer(nz.org.riskscape.rl.ExpressionParser parser, nz.org.riskscape.engine.rl.RealizationContext realizationContext)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    nz.org.riskscape.engine.rl.RealizedExpression
    asStruct(nz.org.riskscape.engine.rl.RealizationContext context, nz.org.riskscape.engine.rl.RealizedExpression expression)
     
    nz.org.riskscape.rl.ast.Expression
    parse(String source)
     
    nz.org.riskscape.problem.ResultOrProblems<nz.org.riskscape.engine.rl.RealizedExpression>
    realize(nz.org.riskscape.engine.types.Type inputType, String source)
     
    nz.org.riskscape.problem.ResultOrProblems<nz.org.riskscape.engine.rl.RealizedExpression>
    realize(nz.org.riskscape.engine.types.Type inputType, nz.org.riskscape.rl.ast.Expression expression)
     
    nz.org.riskscape.problem.ResultOrProblems<nz.org.riskscape.engine.rl.agg.RealizedAggregateExpression>
    realizeAggregate(nz.org.riskscape.engine.types.Type inputType, nz.org.riskscape.rl.ast.Expression expression)
     
    nz.org.riskscape.problem.ResultOrProblems<nz.org.riskscape.engine.rl.RealizedExpression>
    realizeConstant(nz.org.riskscape.rl.ast.Expression expression)
    Attempts to realize the given expression against an empty struct, returning a meaningful problem if it looks like it failed to realize because it had property access problems (meaning it wasn't constant as it relies on the input scope)

    Methods inherited from class java.lang.Object

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

    • DefaultExpressionRealizer

      public DefaultExpressionRealizer(@NonNull @NonNull nz.org.riskscape.engine.rl.RealizationContext context)
    • DefaultExpressionRealizer

      public DefaultExpressionRealizer(nz.org.riskscape.rl.ExpressionParser parser, nz.org.riskscape.engine.rl.RealizationContext realizationContext)
  • Method Details

    • asStruct

      public nz.org.riskscape.engine.rl.RealizedExpression asStruct(nz.org.riskscape.engine.rl.RealizationContext context, nz.org.riskscape.engine.rl.RealizedExpression expression)
      Specified by:
      asStruct in interface nz.org.riskscape.engine.rl.ExpressionRealizer
    • realize

      public nz.org.riskscape.problem.ResultOrProblems<nz.org.riskscape.engine.rl.RealizedExpression> realize(nz.org.riskscape.engine.types.Type inputType, String source)
      Specified by:
      realize in interface nz.org.riskscape.engine.rl.ExpressionRealizer
    • realize

      public nz.org.riskscape.problem.ResultOrProblems<nz.org.riskscape.engine.rl.RealizedExpression> realize(nz.org.riskscape.engine.types.Type inputType, nz.org.riskscape.rl.ast.Expression expression)
      Specified by:
      realize in interface nz.org.riskscape.engine.rl.ExpressionRealizer
    • parse

      public nz.org.riskscape.rl.ast.Expression parse(String source)
      Specified by:
      parse in interface nz.org.riskscape.engine.rl.ExpressionRealizer
    • realizeAggregate

      public nz.org.riskscape.problem.ResultOrProblems<nz.org.riskscape.engine.rl.agg.RealizedAggregateExpression> realizeAggregate(nz.org.riskscape.engine.types.Type inputType, nz.org.riskscape.rl.ast.Expression expression)
      Specified by:
      realizeAggregate in interface nz.org.riskscape.engine.rl.ExpressionRealizer
    • realizeConstant

      public nz.org.riskscape.problem.ResultOrProblems<nz.org.riskscape.engine.rl.RealizedExpression> realizeConstant(nz.org.riskscape.rl.ast.Expression expression)

      Attempts to realize the given expression against an empty struct, returning a meaningful problem if it looks like it failed to realize because it had property access problems (meaning it wasn't constant as it relies on the input scope)

      Specified by:
      realizeConstant in interface nz.org.riskscape.engine.rl.ExpressionRealizer
      Returns:
      a RealizedExpression that is constant, i.e should succeed when called like expr.evaluate(Tuple.EMPTY_TUPLE) and should always return the same result.