Class DefaultBindingContext

java.lang.Object
nz.org.riskscape.engine.bind.DefaultBindingContext
All Implemented Interfaces:
nz.org.riskscape.engine.bind.BindingContext

public class DefaultBindingContext extends Object implements nz.org.riskscape.engine.bind.BindingContext

Various bits of dependency that might be required for parameter binding

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final List<nz.org.riskscape.engine.bind.ParameterBinder>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    DefaultBindingContext(nz.org.riskscape.engine.Project project, nz.org.riskscape.engine.rl.RealizationContext context)
     
    DefaultBindingContext(nz.org.riskscape.engine.Project project, nz.org.riskscape.engine.rl.RealizationContext context, Path tempDir)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> nz.org.riskscape.problem.ResultOrProblems<T>
    bind(Object value, Class<T> expectedType)
    Bind the given value to the required type
    bind(nz.org.riskscape.engine.bind.Parameter param, String value)
    Deprecated.
    Optional<nz.org.riskscape.engine.bind.ParameterBinder>
    getBinder(Class<?> fromType, Class<?> toType)
     
    List<nz.org.riskscape.engine.bind.ParameterBinder>
     
    nz.org.riskscape.engine.Engine
     
    nz.org.riskscape.engine.Project
     
    nz.org.riskscape.engine.rl.RealizationContext
     
    URI that any relative file paths should be resolved against.
    nz.org.riskscape.engine.SRIDSet
     
     
    void
    setBinders(List<nz.org.riskscape.engine.bind.ParameterBinder> binders)
     
    void
    setProject(nz.org.riskscape.engine.Project project)
     
    void
    setSridSet(nz.org.riskscape.engine.SRIDSet sridSet)
     
    void
    validateBoundParameters(List<nz.org.riskscape.engine.bind.Parameter> parameters, Map<String,List<?>> boundParameters)
    Validates a map of already bound parameters against a models set of declared parameters to check their arity and type.
    withNewRelativeTo(URI newRelativeTo)
    Get a new BindingContext with relativeTo Uri set to newRelativeTo.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface nz.org.riskscape.engine.bind.BindingContext

    bind, bindAll, bindAll
  • Field Details

    • DEFAULT_BINDERS

      public static final List<nz.org.riskscape.engine.bind.ParameterBinder> DEFAULT_BINDERS
  • Constructor Details

    • DefaultBindingContext

      public DefaultBindingContext(nz.org.riskscape.engine.Project project, nz.org.riskscape.engine.rl.RealizationContext context)
    • DefaultBindingContext

      public DefaultBindingContext(nz.org.riskscape.engine.Project project, nz.org.riskscape.engine.rl.RealizationContext context, Path tempDir)
  • Method Details

    • withNewRelativeTo

      public DefaultBindingContext withNewRelativeTo(URI newRelativeTo)

      Get a new BindingContext with relativeTo Uri set to newRelativeTo.

      Specified by:
      withNewRelativeTo in interface nz.org.riskscape.engine.bind.BindingContext
      Parameters:
      newRelativeTo - new base URI to resolve relative files against
      Returns:
      binding context with relative to set to newRelativeTo
    • getBinder

      public Optional<nz.org.riskscape.engine.bind.ParameterBinder> getBinder(Class<?> fromType, Class<?> toType)
      Specified by:
      getBinder in interface nz.org.riskscape.engine.bind.BindingContext
      Returns:
      a ParameterBinder for the given java type in modelParameter.
    • bind

      public <T> nz.org.riskscape.problem.ResultOrProblems<T> bind(Object value, Class<T> expectedType)

      Bind the given value to the required type

      Specified by:
      bind in interface nz.org.riskscape.engine.bind.BindingContext
      Returns:
      a bound value, or a failed result describing why the value couldn't be converted
      Throws:
      nz.org.riskscape.engine.bind.NoBindingAvailableException - if there wasn't a binder available. This is thrown, rather than returned in result or problems as this is a system error rather than a user error
    • bind

      @Deprecated public Object bind(nz.org.riskscape.engine.bind.Parameter param, String value)
      Deprecated.
      Specified by:
      bind in interface nz.org.riskscape.engine.bind.BindingContext
    • validateBoundParameters

      public void validateBoundParameters(List<nz.org.riskscape.engine.bind.Parameter> parameters, Map<String,List<?>> boundParameters) throws nz.org.riskscape.engine.bind.InvalidBoundParametersException

      Validates a map of already bound parameters against a models set of declared parameters to check their arity and type.

      Specified by:
      validateBoundParameters in interface nz.org.riskscape.engine.bind.BindingContext
      Throws:
      nz.org.riskscape.engine.bind.InvalidBoundParametersException - if there are problems with number or type of a parameter
    • getEngine

      public nz.org.riskscape.engine.Engine getEngine()
      Specified by:
      getEngine in interface nz.org.riskscape.engine.bind.BindingContext
    • getTempDirectory

      public Path getTempDirectory()
      Specified by:
      getTempDirectory in interface nz.org.riskscape.engine.bind.BindingContext
    • getBinders

      public List<nz.org.riskscape.engine.bind.ParameterBinder> getBinders()
    • setBinders

      public void setBinders(List<nz.org.riskscape.engine.bind.ParameterBinder> binders)
    • getSridSet

      public nz.org.riskscape.engine.SRIDSet getSridSet()
    • setSridSet

      public void setSridSet(nz.org.riskscape.engine.SRIDSet sridSet)
    • getProject

      public nz.org.riskscape.engine.Project getProject()
      Specified by:
      getProject in interface nz.org.riskscape.engine.bind.BindingContext
    • setProject

      public void setProject(nz.org.riskscape.engine.Project project)
    • getRelativeTo

      public URI getRelativeTo()

      URI that any relative file paths should be resolved against.

      Specified by:
      getRelativeTo in interface nz.org.riskscape.engine.bind.BindingContext
    • getRealizationContext

      public nz.org.riskscape.engine.rl.RealizationContext getRealizationContext()
      Specified by:
      getRealizationContext in interface nz.org.riskscape.engine.bind.BindingContext