You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Ryan Bennetts <mo...@gmail.com> on 2014/04/01 05:32:51 UTC

Re: [collections] MultiValueMap with a custom value collection type

Hi Thomas

Thanks very much for your reply. I'll look forward to version 4.1, but in
the meantime I'll go with your suggested code.

Thanks again,

-- Ryan

 > Hello all
> >
> > I am having trouble understanding how to use a custom value collection
> type
> > with a MultiValueMap...
>


> Hi Ryan,
>
> we know that the MultiValueMap is flawed for several reasons, but we are
> working on adding a revamped variant in 4.1, see the issue:
>
> https://issues.apache.org/jira/browse/COLLECTIONS-508
>
> The best thing you can do right now is to instantiate it in the
> pre-generics way:
>
> @SuppressWarnings({ "rawtypes", "unchecked" })
> MultiValueMap<String, String> orderedMap
>   = MapUtils.multiValueMap(new LinkedHashMap(), LinkedHashSet.class);
>
> You actually need type-safety for orderedMap, not for the argument to
> multiValueMap. The need to suppress warnings is annoying, but with 4.1
> this should also go away.
>
> Thomas
>