Add methods to KiwiResources to validate parameters from MultivaluedMaps #604
Labels
new feature
A new feature such as a new class, method, package, group of classes, etc.
Milestone
Add new parameter validation methods in
KiwiResources
that acceptMultivaluedMap
. Even thoughMultivaluedMap
extendsMap
we have run into problems in which the method resolution picks the "wrong" method. See #571 for details, and specifically the@implNote
in the Javadocs inWebTargetHelper
for why having separate methods from the existingvalidateXxxParameter
methods is the right thing to do (despite it being annoying).So, in addition to the
validateIntParameter
andvalidateLongParameter
methods which take aMap<String, V>
(or will, once #603 is implemented), these new methods will specifically acceptMultivaluedMap<String, V>
whereV
is a type parameter.Since
MultivaluedMap
by definition permits more than one value for a key, we will want to have separate methods to handle the cases when you know you only want one parameter (e.g./url?n=42
), and when it's OK to have one or more (e.g./url?n=42&n=84
). So, the new method signatures might look like:One question is whether the
validateOne
methods should throw an exception if there is more than one parameter with the given name? Or, should there be separatevalidateExactlyOne
methods in addition which would be the ones that throw exceptions, whereas the regularvalidateOne
methods just grab the first query parameter with the given name?The text was updated successfully, but these errors were encountered: