commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Carman" <ja...@carmanconsulting.com>
Subject [collections] New MapUtils Methods...
Date Mon, 19 Sep 2005 10:35:58 GMT
How about a couple of new methods in MapUtils?  I don't exactly know what to
call them, but here's their signature:

 

public Map fillMap( Map map, Collection objects, Transformer keyTransformer
);

public Map fillMap( Map map, Collection objects, Transformer keyTransformer,
Transformer valueTransformer );

 

Basically, it just applies the transformer(s) to the collection of objects
to add them to the map.  In the first method, the object itself will be the
value.  Only the two transformer method will actually contain any "guts."
The other method will call it using a TransformerUtils.nopTransformer().  We
had to write this method on our current project and it turned out to be
quite useful.  We had many cases where we wanted to have a map from an
object's id to the object itself.


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message