Re: [morph-developer] Copying Objects to Maps
Brought to you by:
orangeherbert,
sgarlatm
|
From: Matt S. <Mat...@wh...> - 2007-02-26 16:13:03
|
Hi Matt B - I was out of the office on Friday and am just catching up on emails now. I will get back to you today. Matt S Matt Benson wrote: > Follow Up: > > 1) No news is good news, so I will implement such that > beans will indeed map properties to map entries by > default. > > 2) I over-analyzed the issue before; my original idea > of using a PropertyNameMatchingCopier is sufficient to > copy indexed containers to maps, since a basic > reflector will list the string versions of available > indices as property names. :) > > -Matt B > > --- Matt Benson <gud...@ya...> wrote: > > >> SimpleDelegatingTransformer currently uses as its >> last >> two resorts a containerCopier and a >> propertyNameMatchingCopier; attempting to convert a >> POJO to a map results in that object being added to >> the map with a null key (the container copier does >> this by assuming the POJO is a container with a >> single >> component). It is my assertion that the average >> user >> would rather want the POJO's properties mapped as >> key-value pairs in the target map. >> >> My first instinct was to add a >> PropertyNameMatchingCopier with its dest class(es) >> set >> to Map.class just before ContainerCopier. But then >> I >> realized that copying an indexed container to a map >> would be disabled that way. So I wrote an >> ObjectToMapCopier which only matches Map >> destinations >> and extends SDT, delegating first to a >> ContainerCopier >> that only does indexed container reflection, then to >> a >> PropertyNameMatchingCopier. So that it can be used >> beneath SDT, it implements NodeCopier. >> >> Copying >> PropertyNameMatchingCopierTestCase.testCopy() to >> DelegatingCopierTestCase shows that Morph currently >> does not implement this (IMO) reasonable behavior by >> default. By adding ObjectToMapCopier to SDT's >> default >> components list, just before ContainerCopier, we can >> convert POJOs to Maps while continuing to convert >> indexed collections as expected. >> >> I would like to make this change. Any arguments >> against my interpretation of the likely DWIM >> interpretation of "copy this POJO to this Map"??? >> >> -Matt >> >> >> >> >> > ____________________________________________________________________________________ > >> Expecting? Get great news right away with email >> Auto-Check. >> Try the Yahoo! Mail Beta. >> >> > http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html > >> >> > ------------------------------------------------------------------------- > >> Take Surveys. Earn Cash. Influence the Future of IT >> Join SourceForge.net's Techsay panel and you'll get >> the chance to share your >> opinions on IT & business topics through brief >> surveys-and earn cash >> >> > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > >> _______________________________________________ >> morph-developer mailing list >> mor...@li... >> >> > https://lists.sourceforge.net/lists/listinfo/morph-developer > > > > > > ____________________________________________________________________________________ > Do you Yahoo!? > Everyone is raving about the all-new Yahoo! Mail beta. > http://new.mail.yahoo.com > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > morph-developer mailing list > mor...@li... > https://lists.sourceforge.net/lists/listinfo/morph-developer > > |