users@jsr311.java.net

Re: improvement of UriBuider.{query,matrix}Parameters and MultivaluedMap

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 19 Jun 2008 10:33:37 +0200

On Jun 19, 2008, at 9:54 AM, Stephan Koops wrote:

> Hi Marc,
>>>> Maps are OK but what you really need is MultivaluedMap. However,
>>>> I don't want to make that a concrete API class.
>>> For this I proposed to use the parameter Map<String, Object>. If
>>> an value is a Collection (e.g. a List; that's the
>>> MultivaluedMap), than iterate over the values and not directly
>>> call toString() on the collection. And for analogy, I proposed
>>> this for the other methods. And if someone wants to put e.g. the
>>> String "[..., ...]" of an ArrayList into the paramsters (very
>>> rare usecase), he could use list.toString().
>> I wondered if that is what you intended. I'm not really keen on
>> methods that do one thing with one type of parameter and another
>> with a different type. Its complex to explain and document, liable
>> to confuse people and makes the API look and feel overly complex.
> I agree, that it is not a good style. But it allows the use of a
> MultivaluedMap, and it is very easy to use, if someone wants some
> parameters only one times, and other multiple values for some
> parameter keys.
>

We may be unnecessarily overloading functionality in an obtuse manner
for cases are that uncommon. IIUC such cases are possible if the
developer iterates over the entry set of the map.

Paul.