Class PipelineModelParameter

java.lang.Object
nz.org.riskscape.engine.model.ModelParameter
nz.org.riskscape.engine.pipeline.PipelineModelParameter

public class PipelineModelParameter extends nz.org.riskscape.engine.model.ModelParameter

A slightly more specialized ModelParameter that deals specifically with pipelines, i.e. each parameter ultimately needs to be turned back into a pipeline expression.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    PipelineModelParameter(nz.org.riskscape.engine.bind.Parameter parameter, nz.org.riskscape.engine.bind.ParameterTemplate template)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Optional<nz.org.riskscape.rl.ast.Expression>
    bindDefaultValueToExpression(nz.org.riskscape.engine.bind.BindingContext context)
    Binds the default value for this parameter, returning it as an expression.
    nz.org.riskscape.problem.ResultOrProblems<nz.org.riskscape.rl.ast.Expression>
    bindToExpression(nz.org.riskscape.engine.bind.BindingContext context, Object unbound)
    Binds the given object to this parameter, then converts it to an expression suitable for use as a pipeline parameter in a RealizationContext
    List<nz.org.riskscape.problem.Problem>
    checkConstantExpressionStillValid(nz.org.riskscape.engine.bind.BoundParameters bound)
    Validates the final expression before it gets inserted into the pipeline.
    create(String name, nz.org.riskscape.engine.bind.ParameterTemplate template)
     
    create(nz.org.riskscape.engine.bind.BindingContext context, nz.org.riskscape.engine.bind.IdentifiedParameter parameter)
     
    nz.org.riskscape.rl.ast.Expression
    getExpression(nz.org.riskscape.engine.bind.BoundParameters bound)
    Returns the bound value in Expression form.
    withDefaultValue(nz.org.riskscape.engine.bind.BindingContext context, Object value)
    Updates the underlying Parameter with the default value.

    Methods inherited from class nz.org.riskscape.engine.model.ModelParameter

    getChoices, getDescription, getLabel, getName, getParameter, getProperties, getTemplate, toUserFriendlyString

    Methods inherited from class java.lang.Object

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

  • Constructor Details

    • PipelineModelParameter

      public PipelineModelParameter(nz.org.riskscape.engine.bind.Parameter parameter, nz.org.riskscape.engine.bind.ParameterTemplate template)
  • Method Details

    • create

      public static PipelineModelParameter create(nz.org.riskscape.engine.bind.BindingContext context, nz.org.riskscape.engine.bind.IdentifiedParameter parameter)
      Returns:
      a PipelineModelParameter constructed from a (typically project ini defined) IdentifiedParameter, inferring properties from the default value within.
    • create

      public static PipelineModelParameter create(String name, nz.org.riskscape.engine.bind.ParameterTemplate template)
    • withDefaultValue

      public PipelineModelParameter withDefaultValue(nz.org.riskscape.engine.bind.BindingContext context, Object value)

      Updates the underlying Parameter with the default value. If no properties have been defined for the ParameterTemplate, then we can try to infer some basic properties from the default value, e.g. TypedProperty.NUMERIC.

    • bindDefaultValueToExpression

      public Optional<nz.org.riskscape.rl.ast.Expression> bindDefaultValueToExpression(nz.org.riskscape.engine.bind.BindingContext context)

      Binds the default value for this parameter, returning it as an expression. Returns empty if there's no default or if the default value doesn't convert to an expression for some reason.

    • bindToExpression

      public nz.org.riskscape.problem.ResultOrProblems<nz.org.riskscape.rl.ast.Expression> bindToExpression(nz.org.riskscape.engine.bind.BindingContext context, Object unbound)

      Binds the given object to this parameter, then converts it to an expression suitable for use as a pipeline parameter in a RealizationContext

    • getExpression

      public nz.org.riskscape.rl.ast.Expression getExpression(nz.org.riskscape.engine.bind.BoundParameters bound)

      Returns the bound value in Expression form. E.g. we can bind against a ResolvedBookmark value, but then we need to turn that bookmark object back into an expression that will slot into pipeline DSL

    • checkConstantExpressionStillValid

      public List<nz.org.riskscape.problem.Problem> checkConstantExpressionStillValid(nz.org.riskscape.engine.bind.BoundParameters bound)

      Validates the final expression before it gets inserted into the pipeline. This checks that any amendments we've made to the user's value are still valid, but falls short of doing more complicated validation checks as proscribed by the parameter's properties.