Re: [beanutils] adding DynaBean.populate(Map) method?

2002-05-30 Thread James Strachan

From: "Craig R. McClanahan" <[EMAIL PROTECTED]>
> On Thu, 30 May 2002, James Strachan wrote:
>
> > Date: Thu, 30 May 2002 12:34:42 +0100
> > From: James Strachan <[EMAIL PROTECTED]>
>>
> > When working with DynaBeans it might be nice to offer a populate(Map)
method
> > to easily populate a DynaBean from a map where the keys are property
names
> > and the values are the new property values to populate. I've already hit
a
> > use case for this in Jelly.

Actually after further refactoring of code I no longer need this feature
afterall though I may do again in the future...

>> Adding this method to DynaBean would also mirror
> > the BeanUtils.populate(Object bean, Map) method in a more OO way.
> >
>
> Can't you just use BeanUtils.populate() for this already?  It knows (or if
> not it's a bug) how to deal with DynaBeans.

Sure, though BeanUtils.populate() does test for mapped and indexed
properties along with performing conversions. So its fairly heavy weight
(indeed its an argument for not using this mechanism by default in
WrapDynaBean).

My initial motivation for the suggestion was mostly out of cosmetic reasons,
calling dynaBean.populate(Map) is a more natural OO way to do it and to save
folks typing about 4/5 lines of code to iterate over the Map and call
dynaBean.set(name, value) for each Map.Entry..


> Since o.a.c.b.DynaBean is an interface, wouldn't this break every existing
> DynaBean implementation in the world?

Good point. I kinda assumed there'd be a DynaBeanSupport class from which we
all derive, but alas no. So I'm now -1 on my own suggestion for this very
reason.

Maybe we could have a DynaBeanUtils class and make this a static helper
method? We could have a couple of helper factory methods too...

public class DynaBeanUtils {

// does not support indexed or mapped properties
// conversion is done only if the DyanBean implementation supports it
public static void  populate(DynaBean dynaBean, Map map);

// creates a new DynaBean wrapper around a Java Bean that
// may or may not perform automatic conversion on setters
public static void DynaBean newWrapBean(Object bean, boolean
doConversions);
}

Not sure if its worth it though.

James


_
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: [beanutils] adding DynaBean.populate(Map) method?

2002-05-30 Thread Craig R. McClanahan



On Thu, 30 May 2002, James Strachan wrote:

> Date: Thu, 30 May 2002 12:34:42 +0100
> From: James Strachan <[EMAIL PROTECTED]>
> Reply-To: Jakarta Commons Developers List <[EMAIL PROTECTED]>
> To: Jakarta Commons Developers <[EMAIL PROTECTED]>
> Subject: [beanutils] adding DynaBean.populate(Map) method?
>
> When working with DynaBeans it might be nice to offer a populate(Map) method
> to easily populate a DynaBean from a map where the keys are property names
> and the values are the new property values to populate. I've already hit a
> use case for this in Jelly. Adding this method to DynaBean would also mirror
> the BeanUtils.populate(Object bean, Map) method in a more OO way.
>

Can't you just use BeanUtils.populate() for this already?  It knows (or if
not it's a bug) how to deal with DynaBeans.

Since o.a.c.b.DynaBean is an interface, wouldn't this break every existing
DynaBean implementation in the world?

> I'm happy to go ahead and do the work for this if folks agree. Does this
> seem a sensible idea? I'm +1
>
> James
>

Craig


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: [beanutils] adding DynaBean.populate(Map) method?

2002-05-30 Thread Jason van Zyl

On Thu, 2002-05-30 at 07:34, James Strachan wrote:
> When working with DynaBeans it might be nice to offer a populate(Map) method
> to easily populate a DynaBean from a map where the keys are property names
> and the values are the new property values to populate. I've already hit a
> use case for this in Jelly. Adding this method to DynaBean would also mirror
> the BeanUtils.populate(Object bean, Map) method in a more OO way.
> 
> I'm happy to go ahead and do the work for this if folks agree. Does this
> seem a sensible idea? I'm +1

+1
 
> James
> 
> 
> _
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
> 
> 
> --
> To unsubscribe, e-mail:   
> For additional commands, e-mail: 
-- 
jvz.

Jason van Zyl
[EMAIL PROTECTED]

http://tambora.zenplex.org


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: [beanutils] adding DynaBean.populate(Map) method?

2002-05-30 Thread Juozas Baliuka

+1
At 12:34 2002.05.30 +0100, you wrote:
>When working with DynaBeans it might be nice to offer a populate(Map) method
>to easily populate a DynaBean from a map where the keys are property names
>and the values are the new property values to populate. I've already hit a
>use case for this in Jelly. Adding this method to DynaBean would also mirror
>the BeanUtils.populate(Object bean, Map) method in a more OO way.
>
>I'm happy to go ahead and do the work for this if folks agree. Does this
>seem a sensible idea? I'm +1
>
>James
>
>
>_
>Do You Yahoo!?
>Get your free @yahoo.com address at http://mail.yahoo.com
>
>
>--
>To unsubscribe, e-mail:   
>For additional commands, e-mail: 



--
To unsubscribe, e-mail:   
For additional commands, e-mail: