Class ParameterSet

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

public class ParameterSet extends Object

A set of Parameter objects that are grouped together, typically as a set of required inputs for something that a user adds to their project. A ParameterSet is converted in to a BoundParameters object via the bind(BindingContext, Map) method.

  • Field Details

    • EMPTY

      public static final ParameterSet EMPTY

      Somewhat useful constant to represent an empty parameter set

  • Constructor Details

  • Method Details

    • normaliseParameterMap

      public static Map<String,List<?>> normaliseParameterMap(Map<String,?> optionsMap)

      Accepts a wild-card map and returns one where all values are lists. If an existing value is already a List, it's left alone, and everything else (including collections) are returned in a list.

    • from

      public static ParameterSet from(Parameter... declaredParameters)
    • fromList

      public static ParameterSet fromList(Collection<Parameter> declaredParameters)
    • bind

      public BoundParameters bind(BindingContext context, Map<String,List<?>> unbound)

      Attempt to bind the given raw, unbound, parameter values to a BoundParameters object.

      Parameters:
      context - a BindingContext to use to convert values.
      unbound - the values to bind.
      Returns:
      a BoundParameters object with the results of binding. Note that a result is returned even if there were binding errors. A BoundParameters object has map and flatMap methods for treating the BoundParameters object like a ResultOrProblems
    • contains

      public boolean contains(String parameterName)
      Returns:
      if this parameter set contains a parameter with the given name
    • get

      public Parameter get(String parameterName)
      Returns:
      the parameter in this set with the given name, or throw an IllegalArgumentException if no parameter with this name exists in the parameter set.
    • toString

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

      public int size()

      The number of parameters in this set

    • toList

      public List<Parameter> toList()
      Returns:
      the declared parameters within, in the order they were declared
    • 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
    • getDeclared

      public LinkedHashSet<Parameter> getDeclared()