« Return to Thread: Convert List to Map

Convert List to Map

by gonzalad :: Rate this Message:

Reply to Author | View in Thread

Hello,

I have the same question as http://mail-archives.apache.org/mod_mbox/commons-user/200509.mbox/%3C878e7290050905002752ed543d@...%3E :

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());
    }
});

Is there a way to do that with commons collection ?

Thank you very much


 « Return to Thread: Convert List to Map