users@jersey.java.net

[Jersey] ParamaConverterProvider for List<Integer>

From: saadmufti <saad.mufti_at_gmail.com>
Date: Fri, 20 Feb 2015 08:46:07 -0700 (MST)

Hi,

I wanted to register a ParanmConverterProvider that would handle conversion
of a query parameter String to a List<Integer> . I know Jersey supports this
already but the format it uses of

param=val1&param=val2.......&param=valn

was too verbose for us, so we wanted to support something like:

param=val1,val2,val3......,valn

I coded it up to look at rawType and genericType appropriately and
registered it, but then at runtime I saw Jersey never calls my
ParamConverterProvider to ask if it can handle List<Integer> . It seems like
Jersey treats List<T> as a special case to be handled internally only. Is
there a reason for this? The documentation at

https://jersey.java.net/documentation/latest/jaxrs-resources.html#d0e2113

there is a list of rules for how parameter conversions are handled. It
doesn't state precedence explicitly but I got the impression that each item
in the list takes precedence over the previous. Except that item 5 in
practice appears to be "special" and Jersey insists on handling that case
itself using the built in behavior.

Any help would be appreciated. I know I could write a special param class
like IntegerListParam that takes a constructor that can construct it from a
string, but I wanted avoid that ugly extra class.

Any help would be appreciated.




--
View this message in context: http://jersey.576304.n2.nabble.com/ParamaConverterProvider-for-List-Integer-tp7583139.html
Sent from the Jersey mailing list archive at Nabble.com.