You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Danny Lagrouw <da...@gmail.com> on 2005/09/05 09:27:57 UTC

Convert list to map

Hi all,

I need to do a lot of list-to-map conversions, and I'm looking for a way to 
use commons collections for this. I would like to do something like this:

Map map = ListUtils.toMap(list, new SomeTransformerInterface() {
void insertIntoMap(Object object, Map map) {
SpecificObject s = (SpecificObject) object;
map.put(s.getId(), s.getDescription());
}
});

Does something like this exist?
-- 
Regards,
Danny Lagrouw
Java Developer, Profict b.v.

Convert list to map

Posted by Danny Lagrouw <da...@gmail.com>.
Hi all,

I need to do a lot of list-to-map conversions, and I'm looking for a way to 
use commons collections for this. I would like to do something like this:

Map map = ListUtils.toMap(list, new SomeTransformerInterface() {
void insertIntoMap(Object object, Map map) {
SpecificObject s = (SpecificObject) object;
map.put(s.getId(), s.getDescription());
}
});

Does something like this exist?
-- 
Regards,
Danny Lagrouw
Java Developer, Profict b.v.