Class BoundParameters
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 Summary
ConstructorsConstructorDescriptionBoundParameters(ParameterSet boundTo, BindingContext context, Map<String, List<?>> valueMap, Map<String, List<?>> unbound, List<Problem> validationProblems) Creates a newBoundParametersinstance. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanboolean<T> ResultOrProblems<T>flatMap(Function<BoundParameters, ResultOrProblems<T>> function) ResultOrProblemslike method for mapping the parameters in to another ResultOrProblems object, but only if the parameters are validTheParameterSetthat the unbound values were bound toTheBindingContextunder which the parameters were boundThe original, given values that were bound.The bound, valid, values that correspond to theboundToparameter set.List<?>inthashCode()booleanisValid()<T> ResultOrProblems<T>map(Function<BoundParameters, T> function) ResultOrProblemslike method for mapping the parameters in to another object, but only if the parameters are validmerge(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.toString()withMoreProblems(List<Problem> moreProblems) Lets the calling code include more bespoke validation problems besides the straight-forward binding errors.
-
Constructor Details
-
BoundParameters
public BoundParameters(ParameterSet boundTo, BindingContext context, Map<String, List<?>> valueMap, Map<String, List<?>> unbound, List<Problem> validationProblems) Creates a new
BoundParametersinstance.- Parameters:
boundTo- TheParameterSetthat the unbound values were bound tocontext- TheBindingContextunder which the parameters were boundvalueMap- The bound, valid, values that correspond to theboundToparameter set.unbound- 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.validationProblems-
-
-
Method Details
-
getValue
- 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
- Returns:
- the values bound to the parameter with the given name
-
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
ResultOrProblemslike method for mapping the parameters in to another object, but only if the parameters are valid -
flatMap
ResultOrProblemslike method for mapping the parameters in to another ResultOrProblems object, but only if the parameters are valid -
toString
-
merge
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
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
-
canEqual
-
hashCode
public int hashCode() -
getBoundTo
The
ParameterSetthat the unbound values were bound to -
getContext
The
BindingContextunder which the parameters were bound -
getValueMap
The bound, valid, values that correspond to the
boundToparameter set. -
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
- Returns:
- any
Problems encountered during binding - the presence of error-level problems indicates a failed result
-