Class BoundParameters

java.lang.Object
nz.org.riskscape.engine.bind.BoundParameters

public class BoundParameters extends Object

A set of parameter values that have been bound from a particular ParameterSet. While all values should be valid, it's possible that the values are incomplete or there are missing or extra values - the ParameterSet.bind(BindingContext, Map) returns a ResultOrProblems object that will indicate whether the parameters are valid or not

  • Constructor Details

  • Method Details

    • getValue

      public Object getValue(String parameterName)
      Returns:
      the value bound to the parameter with the given name, or null if not set
      Throws:
      IllegalArgumentException - if the parameter has a max arity of greater than one
    • getValues

      public List<?> getValues(String parameterName)
      Returns:
      the values bound to the parameter with the given name
    • getExtraneous

      public Map<String,List<?>> getExtraneous()
      Returns:
      a map of parameters that were given but not used during binding (because they didn't correspond to a parameter in the parameter set). Note that extra parameters do not create a warning or an error.
    • isValid

      public boolean isValid()
    • map

      public <T> ResultOrProblems<T> map(Function<BoundParameters,T> function)

      ResultOrProblems like method for mapping the parameters in to another object, but only if the parameters are valid

    • flatMap

      public <T> ResultOrProblems<T> flatMap(Function<BoundParameters,ResultOrProblems<T>> function)

      ResultOrProblems like method for mapping the parameters in to another ResultOrProblems object, but only if the parameters are valid

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • merge

      public BoundParameters merge(BoundParameters other)

      Merge these bound parameters with other such that any parameter that is set in other will replace one that this set in these bound parameters.

      Parameters:
      other - bound parameters that will set/replace values set in these bound parameters
      Returns:
      new bound parameters with updated parameter values
      Throws:
      IllegalArgumentException - if this and other have a different context or boundTo
    • withMoreProblems

      public BoundParameters withMoreProblems(List<Problem> moreProblems)

      Lets the calling code include more bespoke validation problems besides the straight-forward binding errors.

      Returns:
      a new BoundParameters with the additional problems included.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getBoundTo

      public ParameterSet getBoundTo()

      The ParameterSet that the unbound values were bound to

    • getContext

      public BindingContext getContext()

      The BindingContext under which the parameters were bound

    • getValueMap

      public Map<String,List<?>> getValueMap()

      The bound, valid, values that correspond to the boundTo parameter set.

    • getUnbound

      public Map<String,List<?>> getUnbound()

      The original, given values that were bound. May not be present, depending on how the parameters were created. May also contain values that were not bound, because they were invalid or surplus.

    • getValidationProblems

      public List<Problem> getValidationProblems()
      Returns:
      any Problems encountered during binding - the presence of error-level problems indicates a failed result