Class BaseRealizableFunction

java.lang.Object
nz.org.riskscape.engine.function.BaseRealizableFunction
All Implemented Interfaces:
nz.org.riskscape.engine.rl.RealizableFunction
Direct Known Subclasses:
AppendList, Bounds, Buffer, Call, ConcatList, GeometryPredicateFunction, GeomFromWKT, IfNull, ListLength, MapList, MergeStruct, NullOf, RandomChoice, Reproject, Round, ToTypedCoverage, ZipLists

public abstract class BaseRealizableFunction extends Object implements nz.org.riskscape.engine.rl.RealizableFunction

Base class for DRYing up all the code common to most RealizableFunctions

  • 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
    Modifier and Type
    Field
    Description
    protected final nz.org.riskscape.engine.function.ArgumentList
     
    protected final nz.org.riskscape.engine.types.Type
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    BaseRealizableFunction(nz.org.riskscape.engine.function.ArgumentList arguments, nz.org.riskscape.engine.types.Type returnType)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    nz.org.riskscape.engine.function.RiskscapeFunction
     
    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)
    This method is internal to the sub-class.
    nz.org.riskscape.engine.function.IdentifiedFunction
    builtin(String id, nz.org.riskscape.engine.function.IdentifiedFunction.Category category)
    Shortcut for asFunction().builtin(id, category)
    nz.org.riskscape.engine.function.ArgumentList
     
    nz.org.riskscape.engine.types.Type
     
    nz.org.riskscape.engine.function.IdentifiedFunction
    Shortcut for asFunction().identified(id)
    nz.org.riskscape.problem.ResultOrProblems<nz.org.riskscape.engine.function.RiskscapeFunction>
    realize(nz.org.riskscape.engine.rl.RealizationContext context, nz.org.riskscape.rl.ast.FunctionCall functionCall, List<nz.org.riskscape.engine.types.Type> givenTypes)
    Implements some basic boilerplate error checks by default.

    Methods inherited from class java.lang.Object

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

    • arguments

      protected final nz.org.riskscape.engine.function.ArgumentList arguments
    • returnType

      protected final nz.org.riskscape.engine.types.Type returnType
  • Constructor Details

    • BaseRealizableFunction

      public BaseRealizableFunction(nz.org.riskscape.engine.function.ArgumentList arguments, nz.org.riskscape.engine.types.Type returnType)
  • Method Details

    • asFunction

      public nz.org.riskscape.engine.function.RiskscapeFunction asFunction()
      Returns:
      a RiskscapeFunction that wraps this RealizableFunction. Note that I haven't made this class implements RiskscapeFunction directly as the plan is to re-arrange these classes so that all functions become realizable but are not riskscape functions themselves (until they are realized).
    • identified

      public nz.org.riskscape.engine.function.IdentifiedFunction identified(String id)

      Shortcut for asFunction().identified(id)

    • builtin

      public nz.org.riskscape.engine.function.IdentifiedFunction builtin(String id, nz.org.riskscape.engine.function.IdentifiedFunction.Category category)

      Shortcut for asFunction().builtin(id, category)

    • realize

      public nz.org.riskscape.problem.ResultOrProblems<nz.org.riskscape.engine.function.RiskscapeFunction> realize(nz.org.riskscape.engine.rl.RealizationContext context, nz.org.riskscape.rl.ast.FunctionCall functionCall, List<nz.org.riskscape.engine.types.Type> givenTypes)

      Implements some basic boilerplate error checks by default. This allows simple realizable functions to just define the build(RealizationContext, FunctionCall, List) guts of the function. More complicated realizable functions (i.e. with non-trivial type handling) may want to override this completely.

      Specified by:
      realize in interface nz.org.riskscape.engine.rl.RealizableFunction
    • 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

      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.

      Throws:
      nz.org.riskscape.problem.ProblemException
    • getArguments

      public nz.org.riskscape.engine.function.ArgumentList getArguments()
    • getReturnType

      public nz.org.riskscape.engine.types.Type getReturnType()